Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linaria update to 3.x version #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry = "https://npm.docdoc.pro/"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this change is relevant to the project.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ First, follow craco's
Then, install `craco-linaria` and [Linaria][]:

```bash
$ npm install --save-dev craco-linaria linaria
$ yarn add -D craco-linaria @linaria/core @linaria/babel-preset @linaria/webpack-loader

// or

$ npm install --save-dev craco-linaria @linaria/core @linaria/babel-preset @linaria/webpack-loader
```

## Usage
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "craco-linaria",
"version": "1.1.2",
"version": "3.0.4",
"description": "A craco plugin to use Linaria zero-runtime CSS in JS library in a create react app.",
"keywords": [
"craco",
Expand Down Expand Up @@ -91,7 +91,10 @@
},
"peerDependencies": {
"@craco/craco": "5.x",
"linaria": "1.x",
"@linaria/babel-preset": "3.x",
"@babel/preset-typescript": "7.x",
"@linaria/core": "3.x",
"@linaria/webpack-loader": "3.x",
"react-scripts": "3.x"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('craco-linaria plugin', () => {
).toMatchInlineSnapshot(`
Object {
"transform": Object {
"^.+\\\\.(js|jsx|ts|tsx)$": "${process.cwd()}/src/babelTransform.js",
"^.+\\\\.(js|jsx|mjs|cjs|ts|tsx)$": "${process.cwd()}/src/babelTransform.js",
},
}
`)
Expand Down Expand Up @@ -73,12 +73,12 @@ describe('craco-linaria plugin', () => {
"loader": "/babel-loader/",
"options": Object {
"presets": Array [
"linaria/babel",
"@linaria/babel-preset",
],
},
},
Object {
"loader": "linaria/loader",
"loader": "@linaria/webpack-loader",
"options": Object {
"babelOptions": Object {
"presets": Array [],
Expand Down
11 changes: 10 additions & 1 deletion src/babelTransform.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
const babelJest = require('babel-jest')

module.exports = babelJest.createTransformer({
presets: [require.resolve('babel-preset-react-app'), 'linaria/babel'],
presets: [
[
require.resolve('babel-preset-react-app'),
{
runtime: 'automatic',
},
],
'@babel/preset-typescript',
'@linaria/babel-preset',
],
babelrc: false,
configFile: false,
})
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
}

function overrideJestConfig({ jestConfig }) {
jestConfig.transform['^.+\\.(js|jsx|ts|tsx)$'] = require.resolve(
jestConfig.transform['^.+\\.(js|jsx|mjs|cjs|ts|tsx)$'] = require.resolve(
'./babelTransform.js',
)
return jestConfig
Expand Down Expand Up @@ -66,7 +66,9 @@ function transformBabelLoader(loader, pluginOptions) {
const presets = options.presets || []
options.presets = presets
const { babelOptions, ...linariaOptions } =
pluginOptions || (cosmiconfig('linaria').searchSync() || {}).config || {}
pluginOptions ||
(cosmiconfig('@linaria/babel-preset').searchSync() || {}).config ||
{}

return {
test: loader.test,
Expand All @@ -76,11 +78,11 @@ function transformBabelLoader(loader, pluginOptions) {
loader: loader.loader,
options: {
...options,
presets: presets.concat('linaria/babel'),
presets: presets.concat('@linaria/babel-preset'),
},
},
{
loader: 'linaria/loader',
loader: '@linaria/webpack-loader',
options: {
cacheDirectory: 'src/.linaria_cache',
sourceMap: process.env.NODE_ENV !== 'production',
Expand Down