Skip to content
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

Doesn't support ES6? #132

Closed
geoidesic opened this issue Mar 20, 2020 · 5 comments
Closed

Doesn't support ES6? #132

geoidesic opened this issue Mar 20, 2020 · 5 comments

Comments

@geoidesic
Copy link

geoidesic commented Mar 20, 2020

Hi,

I'm getting this error:

    /Users/me/node_modules/jsonapi-vuex/src/jsonapi-vuex.js:5
    import actions from './actions'
           ^^^^^^^

    SyntaxError: Unexpected identifier

      2 | import { empty, notify } from "src/utils";
      3 | import store from "../store/index";
    > 4 | import { utils } from "jsonapi-vuex";
        | ^
      5 | import { db } from "src/boot/idb";
      6 | import { to } from "await-to-js";
      7 | import { i18n } from "src/boot/i18n";

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
      at Object.<anonymous> (src/api/jvx.js:4:1)

Is this something to do with ES6 support?

@mrichar1
Copy link
Owner

jsonapi-vuex is entirely reliant on es6, as it is built for Vue which uses es6 syntax throughout.

Looking at the error this is most likely caused by Jest not using babel correctly. There are a number of workarounds given in this Jest issue which might help you solve this: jestjs/jest#8660

@geoidesic
Copy link
Author

@geoidesic
Copy link
Author

This is strange because babel is already setup to transpire node_modules.

{
  "plugins": ["@babel/plugin-syntax-dynamic-import"],
  "env": {
    "test": {
      "plugins": ["dynamic-import-node"],
      "presets": [
        [
          "@babel/preset-env",
          {
            "modules": "commonjs",
            "targets": {
              "node": "current"
            }
          }
        ]
      ]
    }
  }
}

@geoidesic
Copy link
Author

Solved:

transformIgnorePatterns: [
    "<rootDir>/node_modules/(?!quasar/lang|jsonapi-vuex)"
  ],

@mrichar1
Copy link
Owner

Great! Thanks for letting me know - no doubt this will hit someone else in the future so good to have a solution! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants