Update: babel to 7.4
See original GitHub issueEnvironment
linaria@1.3.1
@babel/core@7.4.4
@babel/cli@7.4.4
Description
Related https://github.com/babel/babel/issues/9910
There was an issue within babel core with as const
in TypeScript, which was resolved in babel 7.4. Linaria CLI uses old 7.3.3
as dependency.
Reproducible Demo
lerna exec --scope @twisto/theme -- 'linaria --config $LERNA_ROOT_PATH/linaria.config.js --out-dir dist/styles \"src/**/*.tsx\" \"src/**/*.ts\"'
will throw because theme package contains as const
export const createAnimation = <T extends string>(
name: T,
definition: { [percentage: string]: CSSProperties }
) => {
const animationDef = `@keyframe ${name} { ${createCssDefinitionFromObject(
definition
)} }`
return {
name,
definition: animationDef,
} as const
Error:
lerna exec --scope @twisto/theme -- 'linaria --config $LERNA_ROOT_PATH/linaria.config.js --out-dir dist/styles "src/**/*.tsx" "src/**/*.ts"'
lerna notice cli v3.13.4
lerna info versioning independent
lerna info filter [ '@twisto/theme' ]
lerna info Executing command in 1 package: "linaria --config $LERNA_ROOT_PATH/linaria.config.js --out-dir dist/styles \"src/**/*.tsx\" \"src/**/*.ts\""
/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/linaria/node_modules/@babel/core/lib/transformation/normalize-file.js:209
throw err;
^
SyntaxError: /Users/hotell/Projects/devel/twisto/twisto-ui/packages/theme/src/mixins.ts: Unexpected token (25:7)
23 | name,
24 | definition: animationDef,
> 25 | } as const
| ^
26 | }
27 |
28 | const createCssDefinitionFromObject = (definition: {
at Object.raise (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:3831:17)
at Object.unexpected (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:5143:16)
at Object.tsParseNonArrayType (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9269:16)
at Object.tsParseArrayTypeOrHigher (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9273:21)
at Object.tsParseTypeOperatorOrHigher (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9312:120)
at Object.tsParseUnionOrIntersectionType (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9317:16)
at Object.tsParseIntersectionTypeOrHigher (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9335:17)
at Object.tsParseUnionOrIntersectionType (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9317:16)
at Object.tsParseUnionTypeOrHigher (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9339:17)
at Object.tsParseNonConditionalType (/Users/hotell/Projects/devel/twisto/twisto-ui/node_modules/@babel/parser/lib/index.js:9492:17)
Solution
after manually bumping linaria dependencies to latest, issue is resolved as expected, although I would prefer to consume users babel config for transforms 👉 https://github.com/callstack/linaria/blob/master/src/transform.js#L64
"@babel/core": "^7.3.3",
"@babel/core": "^7.4.4",
"@babel/generator": "^7.4.4",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/register": "^7.4.4",
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Upgrade to Babel 7
Upgrade to Babel 7 · All of Babel · Config Lookup Changes · Yearly Preset Deprecations · Stage Preset Deprecations · Remove proposal...
Read more >How to upgrade to babel 7 - Stack Overflow
Use babel-upgrade. Tested on node@10.15.3, npm@6.4.1 and babel@7.4.0. You can use following script. (npx on node 5+ only) npx babel-upgrade ...
Read more >Updating to Babel 7.4 - The Basement
First of all, install the latest version of core-js · Update your .babelrc Make sure you explicitly set the version of core-js ....
Read more >@babel/core - npm
Babel compiler core.. Latest version: 7.20.7, last published: 4 days ago. Start using @babel/core in your project by running `npm i ...
Read more >Update to Babel 7.4 and core-js 3 #15139 - GitHub
Description Specifies the version of core-js used in the package (Gutenberg uses 2.x at the moment) to prevent warnings. How has this been...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure we’ll take that into account 👍
We currently use babel
7.9