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

imports-loader rule is not compatible with imports-loader@3.0.0 #653

Open
tensory opened this issue Jul 19, 2021 · 2 comments
Open

imports-loader rule is not compatible with imports-loader@3.0.0 #653

tensory opened this issue Jul 19, 2021 · 2 comments

Comments

@tensory
Copy link

tensory commented Jul 19, 2021

I'm using Webpack 5.45.1 and imports-loader 3.0.0.

The suggestion in the Readme to use imports-loader with an argument use: "imports-loader?this=>window,fix=>module.exports=0" is not compatible with latest imports-loader.

I was able to get the bundle file to build using this rule, updated using imports-loader 3.0.0 docs:

module: {
    rules: [
      // snapsvg depends on imports-loader
      {
        test: require.resolve('snapsvg/dist/snap.svg.js'),
        // not working!
        // use: 'imports-loader?this=>window,fix=>module.exports=0',
        use: [
          {
            loader: "imports-loader",
            options: {
              wrapper: "window",
              additionalCode: "module.exports=0"
            }
          }
        ],
      },
    ],
    ...

I would love to contribute this update as a pull request to the Readme. Unfortunately I'm still getting an error at runtime about Uncaught ReferenceError: eve is not defined, so it didn't solve the underlying problem that I thought the rule might address.

@hailie-rei
Copy link

@tensory
Hi, I faced the same issue for Webpack 5, and I solved it by using https://github.com/ThomasOrlita/Snap.svg-cjs. No need to use imports-loader.

Just import Snap from "snapsvg-cjs";

@abid-mujtaba
Copy link

This can be solved without having to switch to a different project using the solution in #639

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

3 participants