SyntaxError: Cannot use import statement outside a module
See original GitHub issueDescription
When i try to use an imported variables in linaria css, it gives this error, seems to come from @linaria/webpack-loader:
/sandbox/node_modules/@ui5/webcomponents-react-base/dist/index.js:1
(function (exports) { import * as Device from './Device';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at new Script (vm.js:102:7)
at Module.evaluate (/sandbox/node_modules/@linaria/webpack4-loader/node_modules/@linaria/babel-preset/lib/module.js:290:20)
Reproducible Demo
Please refer to this code sandbox: https://codesandbox.io/s/linaria-demo-forked-1kwhyy?file=/src/App.js
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
"Uncaught SyntaxError: Cannot use import statement outside ...
This means that you're using the native source code in an unaltered/unbundled state, leading to the following error: Uncaught SyntaxError: ...
Read more >Cannot use import statement outside module in JavaScript
The "SyntaxError: Cannot use import statement outside a module" occurs when we use the ES6 Modules syntax in a script that was not...
Read more >How to fix "cannot use import statement outside a module"
I stumbled on this error: Uncaught SyntaxError: cannot use import statement outside a module while importing a function from a JavaScript file.
Read more >Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error.
Read more >How to solve: cannot use import statement outside a module
When you see the error message Uncaught SyntaxError: cannot use import statement outside a module, it means you're using an import statement ......
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 Free
Top 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

It seems linaria webpack-loader need to transpile all @ui5 and lit-html packages to ES5
By default, Linaria doesn’t transpile modules inside
node_modules. However, you can add a rule for a specific folder (seerulesoptions). For your case,linaria.config.jswill look like this: