Skip to content

Importing a node module from react-spring/renderprops transforms it into an ES module and fails to run in node #8186

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

Closed
slikts opened this issue Mar 21, 2019 · 5 comments

Comments

@slikts
Copy link
Contributor

slikts commented Mar 21, 2019

🐛 Bug Report

When importing a node module from react-spring/renderprops, it appears to be transformed to an ES module and fails to run.

    react-spring-bundle-example/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export default function _objectWithoutPropertiesLoose(source, excluded) {
                                                                                             ^^^^^^

    SyntaxError: Unexpected token export

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:451:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:493:19)
      at Object.<anonymous> (node_modules/react-spring/renderprops.js:7:53)

The imported module is not an ES module, so the source of the issue is unclear: https://unpkg.com/[email protected]/renderprops.js

Related issue: pmndrs/react-spring#601

To Reproduce

Minimal example repo: https://github.com/slikts/react-spring-bundle-example/

git clone [email protected]:slikts/react-spring-bundle-example.git .
npm i
npx jest

Expected behavior

Tests run without errors.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 11.9.0 - /usr/local/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.5.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^24.5.0 => 24.5.0
@neyron163
Copy link

Did you try add? /renderprops.cjs link

@slikts
Copy link
Contributor Author

slikts commented May 16, 2019

Importing the .cjs module is just a workaround, and both modules are actually CJS (or more accurately, node modules; pmndrs/react-spring#601) and don't have ES6 module syntax; the ES6 module syntax is added by Jest somehow, which causes the error.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants