question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EvalError: Unexpected token 'export' in

See original GitHub issue

Environment

  • Linaria version: 4.1.0
  • Bundler (+ version): webpack 5.78
  • Node.js version: 16
  • OS: ubuntu

Description

➤ YN0000: /home/circleci/project/node_modules/@linaria/babel-preset/lib/module.js:384
➤ YN0000:         throw new EvalError(`${e.message} in${callstack.join('\n| ')}\n`);
➤ YN0000:         ^
➤ YN0000: 
➤ YN0000: EvalError: Unexpected token 'export' in
➤ YN0000: | /home/circleci/project/node_modules/antd/es/index.js
➤ YN0000: | src/app/App.tsx
➤ YN0000: 
➤ YN0000:     at /home/circleci/project/node_modules/@linaria/babel-preset/lib/module.js:384:15
➤ YN0000:     at Array.forEach (<anonymous>)
➤ YN0000:     at Module.evaluate (/home/circleci/project/node_modules/@linaria/babel-preset/lib/module.js:361:10)
➤ YN0000:     at require.Object.assign.ensure (/home/circleci/project/node_modules/@linaria/babel-preset/lib/module.js:319:11)
➤ YN0000:     at src/app/App.tsx:1:46
➤ YN0000:     at src/app/App.tsx:2:3
➤ YN0000:     at Script.runInContext (node:vm:139:12)
➤ YN0000:     at /home/circleci/project/node_modules/@linaria/babel-preset/lib/module.js:368:16
➤ YN0000:     at Array.forEach (<anonymous>)
➤ YN0000:     at Module.evaluate (/home/circleci/project/node_modules/@linaria/babel-preset/lib/module.js:361:10)

Seems related to babel doing a transform it shouldn’t?

Reproducible Demo

https://github.com/ntucker/anansi/pull/1591

  1. git clone https://github.com/ntucker/anansi
  2. git checkout renovate/major-linaria
  3. yarn install
  4. yarn build:pkg
  5. cd examples/concurrent
  6. yarn build

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:18

github_iconTop GitHub Comments

1reaction
Anbercommented, Jul 26, 2022

It supports if it is an mjs file with fully specified imports. But if you check node_modules/antd/es/index.js in your project, you will see that the file itself is not mjs, and all imports inside don’t have extensions.

0reactions
Anbercommented, Jul 27, 2022

in case these are not used for any linaria computations

In that specific case antd is used, because styled have to know the type of component it wraps and that’s why Linaria tries to evaluate it. However, inners of antd can be treeshaked a bit more effectively.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Unexpected Token Export - javascript
I am trying to run some ES6 code in my project but I am getting an unexpected token export error.
Read more >
How to fix SyntaxError: Unexpected token 'export' in ...
In this article, we are going to see How to fix SyntaxError: Unexpected token 'export' in JavaScript? and what are Es6 modules.
Read more >
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
SyntaxError: Unexpected token - JavaScript
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
SyntaxError: Unexpected token 'export' - Abhishek Kumar
In case you are getting error like 'Unexpected token export' while starting the server, then export like below in schema.js
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found