-
Notifications
You must be signed in to change notification settings - Fork 353
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
root in strict mode refer to undefined #111
Comments
I am having the same problem. How can we set this up to be able to pass something else? |
If you use webpack this can help you require("imports?this=>window!./file.js") or require("imports?this=>global!./file.js") |
+1 |
Yeah, this is no good. I think it'd be better to convert lib/svg4everybody.js into a CJS module so that bundlers can do what they do best, rather than bundling the generated UMD. This would mean:
How's this sound? |
Temporary solution
|
@shawnbot I think its good to support 3 types |
I was experiencing a similar issue with webpack + babel, where import would throw:
Turned out that I had forgotten to exclude the node_modules directory from the babel-loader: loaders: [{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel'
}] Maybe you need to do the same? |
I am seeing the same behaviour with gulp-babel. I'm not using Webpack or any other bundler. |
I've got this issue fixed for now. The solution involves using a different Babel preset that does not change
I'll continue testing on projects that are browser facing and don't require modules. |
+1 @damienmcd just tried your approach (thanks!) and it worked for some browsers (Chrome for instance), but not older ones like IE10/11, where I'm still getting this passed in as undefined. Anyone else seeing the same? FWIW: I ended up taking the approach of including the lib JS file instead of the dist version. |
Can we all just say window when we mean window. |
Same issue here:
Installed Webpack-config (using module: {
rules: [
{
test: /.js$/,
use: [
{
loader: "babel-loader"
}
]
}
]
} main.js import svg4everybody from 'svg4everybody'; |
After a little bit more research I fixed this by adding module: {
rules: [
{
test: /.js$/,
exclude: /node_modules(?!\/foundation-sites|flickity)/,
use: [
{
loader: "babel-loader"
}
]
}
]
} |
Had the same issue. module: {
loaders: [
{
test: /\.js?$/,
exclude: /node_modules\/svg4everybody/,
loader: 'babel-loader',
},
],
}, |
I have the same issue when using the script in a file with |
Possible duplicate of #162 |
See #171 |
add |
|
My bundler (webpack + babel) add 'use sctrict' to every module automatically so that
this
in last line isundefined
The text was updated successfully, but these errors were encountered: