Still receive syntax error for dynamic import with babel-plugin-syntax-dynamic-import when running with mocha

Kirby Simmons

All babel modules/plugins are on the latest version of babel v6. Mocha is on v4.0.1.

Setup:

// .babelrc
{
   presets: [
      "stage-3",
      [
         "env",
         {
           "targets": {
              "browsers": [
                "last 2 versions"
              ],
              "node": "current"
           }
         }
      ]
      "react"
   ],
   plugins: ["transform-runtime", "syntax-dynamic-import"]
}


// mocha.opts
--recursive
--reporter progress
--require babel-polyfill
--require babel-register
--timeout 20000

So when I run my test suite I still get: error stack trace.

I would have to imagine it has something to do with babel-register and syntax-dynamic-import not working together correctly. Because when I use it with babel-loader in webpack I don't get any syntax errors on transpile.

Kirby Simmons

This answer on babeljs slack from Satyajit Sahoo cleared things up for me:

syntax-dynamic-import will only enable the syntax in babylon, which means it babylon can parse the code without syntax error. the code import(...) is still there, which node doesn’t understand and you still need to transpile it. dynamic-import-node transpiles the import(...) to require which node understands. On client, the transpilation step is not necessary since Webpack understands the syntax and does the bundling.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Webpacker error related to module babel-plugin-syntax-dynamic-import

From Dev

Syntax Error on dynamic import() using webpack and babel

From Dev

@babel/plugin-syntax-dynamic-import not working in imported node module

From Dev

webpacker Uncaught Error: Module build failed / Cannot find module 'babel-plugin-syntax-dynamic-import'

From Dev

Add @babel/plugin-syntax-dynamic-import to the 'plugins' section of your Babel config to enable parsing. after migrating angular to 13

From Dev

VS Code Dynamic Import syntax error statement expected

From

Babel unexpected token import when running mocha tests

From Dev

unexpected token import when using Mocha with Babel

From Dev

Curious sql import syntax error

From Dev

Syntax error with a simple Python import

From Dev

babel-eslint does not allow dynamic import

From Dev

Cannot read property 'then' of undefined | When i try to import a component with babel-dynamic-import

From Dev

Sql dynamic query syntax error

From Dev

Postgresql dynamic sql syntax error

From Dev

Make a dynamic import which is still explicit in Python

From Dev

Unresolved import error E0432 when creating a syntax extension

From Dev

Syntax error when trying to import CSV with Hash symbol

From Dev

Syntax error when trying to import Cntlr from arelle module

From Dev

Syntax error when passing dynamic value to sql query in node js

From Dev

Python Dynamic Import import as

From Dev

Uncaught Error: Cannot Find Module When Using Dynamic Import for JavaScript

From Dev

Uncaught syntax error when using ES-6 import syntax in Chrome

From Dev

Error when running SQL syntax

From Dev

How to import class using ES6 syntax? (without Babel)

From Dev

Jinja2.5 Syntax error on import

From Dev

ChromeOptions() import is not working in python selenium syntax error?

From Dev

Relative Dynamic Loading with systemJS, using ES6/Babel syntax

From Dev

From flask import Flask fails with Syntax error: invalid syntax

From Dev

"Unexpected token ." when using optional chaning "?." syntax when running mocha

Related Related

  1. 1

    Webpacker error related to module babel-plugin-syntax-dynamic-import

  2. 2

    Syntax Error on dynamic import() using webpack and babel

  3. 3

    @babel/plugin-syntax-dynamic-import not working in imported node module

  4. 4

    webpacker Uncaught Error: Module build failed / Cannot find module 'babel-plugin-syntax-dynamic-import'

  5. 5

    Add @babel/plugin-syntax-dynamic-import to the 'plugins' section of your Babel config to enable parsing. after migrating angular to 13

  6. 6

    VS Code Dynamic Import syntax error statement expected

  7. 7

    Babel unexpected token import when running mocha tests

  8. 8

    unexpected token import when using Mocha with Babel

  9. 9

    Curious sql import syntax error

  10. 10

    Syntax error with a simple Python import

  11. 11

    babel-eslint does not allow dynamic import

  12. 12

    Cannot read property 'then' of undefined | When i try to import a component with babel-dynamic-import

  13. 13

    Sql dynamic query syntax error

  14. 14

    Postgresql dynamic sql syntax error

  15. 15

    Make a dynamic import which is still explicit in Python

  16. 16

    Unresolved import error E0432 when creating a syntax extension

  17. 17

    Syntax error when trying to import CSV with Hash symbol

  18. 18

    Syntax error when trying to import Cntlr from arelle module

  19. 19

    Syntax error when passing dynamic value to sql query in node js

  20. 20

    Python Dynamic Import import as

  21. 21

    Uncaught Error: Cannot Find Module When Using Dynamic Import for JavaScript

  22. 22

    Uncaught syntax error when using ES-6 import syntax in Chrome

  23. 23

    Error when running SQL syntax

  24. 24

    How to import class using ES6 syntax? (without Babel)

  25. 25

    Jinja2.5 Syntax error on import

  26. 26

    ChromeOptions() import is not working in python selenium syntax error?

  27. 27

    Relative Dynamic Loading with systemJS, using ES6/Babel syntax

  28. 28

    From flask import Flask fails with Syntax error: invalid syntax

  29. 29

    "Unexpected token ." when using optional chaning "?." syntax when running mocha

HotTag

Archive