mrichar1 / jsonapi-vuex

Use a JSONAPI api with a Vuex store, with data restructuring/normalization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't support ES6?

geoidesic opened this issue · comments

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?

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

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"
            }
          }
        ]
      ]
    }
  }
}

Solved:

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

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