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

how to use this in cra project? #643

Open
Kilims opened this issue Dec 4, 2020 · 3 comments
Open

how to use this in cra project? #643

Kilims opened this issue Dec 4, 2020 · 3 comments

Comments

@Kilims
Copy link

Kilims commented Dec 4, 2020

in webpack config with [email protected]

{
            test: require.resolve('snapsvg/dist/snap.svg.js'),
            use: 'imports-loader?this=>window,fix=>module.exports=0',
        },

not working, and saying

ValidationError: Invalid options object. Imports Loader has been initialized using an options object that does not match the API schema.
 - options should be one of these:
   object { imports, … } | object { wrapper, … } | object { additionalCode, … }
   Details:
    * options has an unknown property 'this'. These properties are valid:
      object { imports, … } | object { wrapper, … } | object { additionalCode, … }
    * options has an unknown property 'fix'. These properties are valid:
      object { imports, … } | object { wrapper, … } | object { additionalCode, … }
    * options misses the property 'imports' | should be any non-object.
    * options misses the property 'wrapper' | should be any non-object.
    * options misses the property 'additionalCode' | should be any non-object.

suppose i should modify it as following

{
            test: require.resolve('snapsvg/dist/snap.svg.js'),
            use: [
            {
                loader: 'imports-loader',
                // some config
            }
        ],
        },

but how to config it as the same as 'imports-loader?this=>window,fix=>module.exports=0' ?

@sampathkumarm
Copy link

Same issue with me, I tried inline as shown below but no luck.
const Snap = require(imports-loader?imports=default|snapsvg|Snap&wrapper=window&!snapsvg/dist/snap.svg.js);

@abid-mujtaba
Copy link

This should work: #639 (comment)

@Asphiii
Copy link

Asphiii commented Feb 20, 2023

This should work: #639 (comment)

I can confirm - works perfectly with Webpack 5

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

4 participants