adobe-webplatform / Snap.svg

The JavaScript library for modern SVG graphics.
http://snapsvg.io
Apache License 2.0
13.95k stars 1.15k forks source link

Webpack(Imports Loader v1.x, v2.x) not work #639

Open hrkksm10 opened 4 years ago

hrkksm10 commented 4 years ago

not work

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

work

module: {
  rules: [
    {
      test: require.resolve('snapsvg/dist/snap.svg.js'),
      use: 'imports-loader?wrapper=window&additionalCode=module.exports=0;',
    },
  ],
},
lt2396261331 commented 2 years ago

oh thank's

abid-mujtaba commented 1 year ago

The corresponding config in expanded format (verified to work with webpack@"^5.75.0" and imports-loader@"^4.0.1"):

    module: {
        rules: [
            {
                test: require.resolve('snapsvg/dist/snap.svg.js'),
                use: [
                    {
                        loader: 'imports-loader',
                        options: {
                            wrapper: 'window',
                        }
                    },
                    {
                        loader: 'imports-loader',
                        options: {
                            additionalCode: 'module.exports = 0;'
                        }
                    }
                ]
            }
        ]
    }