yumauri / effector-storage

Module for Effector ☄️ to sync stores with `localStorage` (or `sessionStorage`)
MIT License
105 stars 3 forks source link

Error on import 'effector-storage/local' #12

Closed syabro closed 3 years ago

syabro commented 3 years ago
ERROR in ./node_modules/effector-storage/local/index.js 1:58-95
Module not found: Error: Can't resolve '../storage' in '/xxx/node_modules/effector-storage/local'
Did you mean 'index.js'?
BREAKING CHANGE: The request '../storage' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
  xxx
 @ ./src/app.tsx 3:0-41 15:15-20
 @ ./src/index.tsx 2:0-26 4:9-12
syabro commented 3 years ago

Solved by adding to webpack config

           {
                test: /\.m?js/,
                resolve: {
                    fullySpecified: false
                }
            },

https://github.com/graphql/graphql-js/issues/2721#issuecomment-723008284

(In case if someone would stuck on the same problem)

yumauri commented 3 years ago

Thank you for reporting this! From the attached link I assume you are using Webpack 5, correct? This is strange, actually, because /storage/ has package.json file inside, with entry point for "module", and Webpack should respect it... I'll try to investigate this.

syabro commented 3 years ago

@yumauri yup, webpack 5.

yumauri commented 3 years ago

I've published version 4.0.2, should fix the issue. Didn't try on different bundlers though, but Webpack 5 looks like working fine without any config adjustments. @syabro Can you try new version, please?

syabro commented 3 years ago

@yumauri seems fine. Thanks.

yumauri commented 3 years ago

To be sure this case is closed, I tried to make an extended investigation with different popular bundlers. Now I can be at least pretty sure all major bundlers are working fine with my module :)

Bundler 4.0.2 4.0.3 4.2.0
Webpack 1 (babel 6 loader + es2015 preset + effector/compat)
Webpack 2 (babel 7 loader + env preset)
Webpack 3 (babel 7 loader + env preset)
Webpack 4
Webpack 5
Parcel 1
Parcel 2
Rollup
Snowpack
esbuild
FuseBox 3 ❌ (👀)
FuseBox 4
Browserify (with require syntax) -
Poi -

There was an issue with FuseBox 3, it has hardcoded .js extension to lookup files, so .cjs files weren't working, and esm weren't working also, I don't know why... So, I've published version 4.0.3, the only difference is that CommonJS modules now have an extension .cjs.js

yumauri commented 3 years ago

In the version 4.2.0 I've decided to change .cjs.js extensions back to .cjs. I've tested all bundlers, and everything is working fine, aside from FuseBox3. Which I abandon.