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

"export 'default' (imported as 'stringify') was not found in 'fast-json-stable-stringify' #399

Closed
klaus1978 opened this issue Dec 25, 2019 · 24 comments

Comments

@klaus1978
Copy link

@klaus1978 klaus1978 commented Dec 25, 2019

Hi,
After updating from v2.3.1 to v3.2.1 I now get the error message:
"export 'default' (imported as 'stringify') was not found in 'fast-json-stable-stringify'

index.js?a08a:3 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#'
at Module.eval (index.js?a08a:3)
at eval (index.js:84)
at Module../node_modules/feathers-vuex/node_modules/fast-json-stable-stringify/index.js (vendors.app.js:4344)
at webpack_require (runtime.js:791)
at fn (runtime.js:151)
at Module.eval (utils.js:69)
at eval (utils.js:537)
at Module../node_modules/feathers-vuex/dist/utils.js (vendors.app.js:4320)
at webpack_require (runtime.js:791)
at fn (runtime.js:151)

Going back to a version <3.xx seems to solve the issue again

KR Klaus

@markneub

This comment has been minimized.

Copy link

@markneub markneub commented Dec 26, 2019

Same problem here, migrating from 2.3.0 to 3.2.1

@J3m5

This comment has been minimized.

Copy link
Contributor

@J3m5 J3m5 commented Dec 26, 2019

Did you try to delete the node_modules folder and do a fresh install?

@markneub

This comment has been minimized.

Copy link

@markneub markneub commented Dec 26, 2019

Yep, no dice. FWIW, my app was bootstrapped with vue-cli 4.0.5.

$ vue --version
@vue/cli 4.0.5
@J3m5

This comment has been minimized.

Copy link
Contributor

@J3m5 J3m5 commented Dec 26, 2019

And did you add the transpileDependencies option in the vue.config.js file?

@markneub

This comment has been minimized.

Copy link

@markneub markneub commented Dec 26, 2019

Yep:

// vue.config.js
module.exports = {
  lintOnSave: false,
  transpileDependencies: ['feathers-vuex'],

  chainWebpack: config => {
    config.module
        .rule("vue")
        .use("vue-svg-inline-loader")
            .loader("vue-svg-inline-loader")
            .options({ /* ... */ });
  }
}
@markneub

This comment has been minimized.

Copy link

@markneub markneub commented Dec 27, 2019

I was able to fix this locally with babel-plugin-transform-commonjs-es2015-modules:

yarn add babel-plugin-transform-commonjs-es2015-modules --dev
// babel.config.js
module.exports = {
  plugins: ['transform-commonjs-es2015-modules'],
  presets: [
    '@vue/cli-plugin-babel/preset'
  ]
}

No idea why this suddenly broke, though...

From what I can gather, when babel tries to transpile feathers-vuex, it chokes on the fast-json-stable-stringify dependency which uses a CommonJS module export. But nothing seems to have changed recently in that export or in the corresponding import in feathers-vuex. So I'm not sure why it ever worked — or rather since I'm not understanding why it worked, why it broke.

@klaus1978

This comment has been minimized.

Copy link
Author

@klaus1978 klaus1978 commented Dec 27, 2019

Hey @markneub ,
unfortunately your solution is not working for me.
Differences: I created the app with create-nuxt-app

Do I have to add babel.config.js to another file (eg nuxt.config.js) to make it work or is it working for you just as explained above?
BTW: I also tried
.babelrc

{
  "plugins": ["transform-commonjs-es2015-modules"]
}

KR

@markneub

This comment has been minimized.

Copy link

@markneub markneub commented Dec 27, 2019

Hey @klaus1978, all I had to do to get my setup working is what I explained above. Since you're using Nuxt I expect it will be a little different.

From the Nuxt docs on modifying your babel configuration, it looks like you could maybe try adding something like the following:

// nuxt.config.js
module.exports = {
  // (maybe some existing config here)
  build: {
    babel: {
      plugins: ['transform-commonjs-es2015-modules']
    }
  }
}
@klaus1978

This comment has been minimized.

Copy link
Author

@klaus1978 klaus1978 commented Dec 27, 2019

Hey @markneub ,
you made it! I added exactly that to nuxt.config.js and the error is gone ;-)

Thanks a lot
Klaus

@marshallswain

This comment has been minimized.

Copy link
Member

@marshallswain marshallswain commented Dec 30, 2019

Thanks for reporting, @klaus1978 and @markneub . I haven't run into this issue, yet. I'll leave this open for a while before I either update the docs or find another solution that doesn't require a workaround.

@andysay

This comment has been minimized.

Copy link

@andysay andysay commented Dec 31, 2019

Hey @klaus1978, all I had to do to get my setup working is what I explained above. Since you're using Nuxt I expect it will be a little different.

From the Nuxt docs on modifying your babel configuration, it looks like you could maybe try adding something like the following:

// nuxt.config.js
module.exports = {
  // (maybe some existing config here)
  build: {
    babel: {
      plugins: ['transform-commonjs-es2015-modules']
    }
  }
}

not work with i18n-nuxt

TypeError: Cannot read property 'loadLanguageAsync' of undefined
    at _callee$ (plugin.main.js?cf89:127)
    at tryCatch (runtime.js?96cf:65)
    at Generator.invoke [as _invoke] (runtime.js?96cf:303)
    at Generator.prototype.<computed> [as next] (runtime.js?96cf:117)
    at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
    at _next (asyncToGenerator.js?1da1:25)
    at eval (asyncToGenerator.js?1da1:32)
    at new Promise (<anonymous>)
    at eval (asyncToGenerator.js?1da1:21)
    at loadAndSetLocale (plugin.main.js?cf89:32)
@marshallswain

This comment has been minimized.

Copy link
Member

@marshallswain marshallswain commented Dec 31, 2019

It's a pretty light-weight module, so maybe the best solution would be to bring the fast-json-stable-stringify utility directly into feathers-vuex: https://github.com/epoberezkin/fast-json-stable-stringify/blob/master/index.js

That would make it so we don't have to do the babel workaround.

@klaus1978

This comment has been minimized.

Copy link
Author

@klaus1978 klaus1978 commented Dec 31, 2019

Hey @marshallswain ,
just tell me what to do and I am happy to test it.
KR klaus

@guzz

This comment has been minimized.

Copy link
Contributor

@guzz guzz commented Jan 15, 2020

I'm having a similar problem with 'sift':

"export 'default' (imported as 'sift') was not found in 'sift'

I fixed with:

// nuxt.config.js
module.exports = {
  // (maybe some existing config here)
  build: {
    babel: {
      sourceType: 'unambiguous'
    }
  }
}
@J3m5

This comment has been minimized.

Copy link
Contributor

@J3m5 J3m5 commented Jan 15, 2020

This issue need some love.
Implemented is this PR but the author is not really motivated to add a build step.

@marshallswain

This comment has been minimized.

Copy link
Member

@marshallswain marshallswain commented Jan 15, 2020

I'm still not sure how to reproduce this issue. Does anybody have a repo they can share?

@abdonrd

This comment has been minimized.

Copy link

@abdonrd abdonrd commented Jan 28, 2020

Please, if you can, comment there! epoberezkin/fast-json-stable-stringify#10

Maybe seeing more interested people we can reach a solution soon.

@inghuguesboni

This comment has been minimized.

Copy link

@inghuguesboni inghuguesboni commented Feb 22, 2020

Hi!
I'm having a similar error with Quasar framework using feathers-vuex version 3.6.1.
After updating my babel.config.js to:

//babel.config.js
module.exports = {
  presets: [
    '@quasar/babel-preset-app'
  ],
  plugins: ['transform-commonjs-es2015-modules']
}

I'm getting:

error  in ./node_modules/feathers-vuex/node_modules/@feathersjs/commons/lib/index.js

Module parse failed: 'import' and 'export' may only appear at the top level (5:36)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js

@sebastien-prudhomme

This comment has been minimized.

Copy link

@sebastien-prudhomme sebastien-prudhomme commented Feb 22, 2020

@inghuguesboni did you fix quasar.confwith this:

      transpileDependencies: [
        'feathers-vuex'
      ]
@andysay

This comment has been minimized.

Copy link

@andysay andysay commented Feb 22, 2020

after update to last version problem has fixed !
who have error with sift need update config

// nuxt.config.js
module.exports = {
  // (maybe some existing config here)
  build: {
    babel: {
      sourceType: 'unambiguous'
    }
  }
}
@J3m5

This comment has been minimized.

Copy link
Contributor

@J3m5 J3m5 commented Feb 22, 2020

Just for information, my solution (it might not be appropriate for you) is to set

 "browserslist": [
    "Chrome >= 55"
  ],

in package.json.

@inghuguesboni

This comment has been minimized.

Copy link

@inghuguesboni inghuguesboni commented Feb 23, 2020

@inghuguesboni did you fix quasar.confwith this:

      transpileDependencies: [
        'feathers-vuex'
      ]

Yes I have it. Here is my quasar.conf.js / build:

//quasar.conf.js   build
...
build: {
      scopeHoisting: true,
      transpileDependencies: ['feathers-vuex'],
      extendWebpack (cfg) {
        cfg.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /node_modules/,
          options: {
            formatter: require('eslint').CLIEngine.getFormatter('stylish')
          }
        })
      }
    },
...
@itoonx

This comment has been minimized.

Copy link

@itoonx itoonx commented Mar 2, 2020

Update your file like this to fix this problem
nuxt-config.js

build: {
    transpile: ['feathers-vuex'],
    babel: {
      sourceType: 'unambiguous'
    }
}
@marshallswain

This comment has been minimized.

Copy link
Member

@marshallswain marshallswain commented Mar 14, 2020

I've added a section in the docs to both the Getting Started page and the Nuxt page that links to this issue as a reference for those who have build issues. I still have yet to run into this issue, at all.

Since this isn't something that can be resolved in a satisfactory manner inside feathers-vuex, I'm closing the issue.

https://vuex.feathersjs.com/nuxt.html#resolving-build-issues
https://vuex.feathersjs.com/getting-started.html#resolving-build-issues

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

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.