-
Notifications
You must be signed in to change notification settings - Fork 630
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
Issue when requiring is.js with webpack #100
Comments
I'm having the issue as well. This way webpack pretends to be a amd loader and work well. The old way tries to locate module 'is' in your modules path instead of simply getting file 'is.js' in current dir. Another way to workaround it, is to add |
Checking the UMD recommendation mentioned in e6c2b0c, I now believe that it was applied wrong. Their example https://github.com/umdjs/umd/blob/master/returnExportsGlobal.js, which seems to be basis of the implementation, shows how to create a module that depend on another module (b in their case). The actual is_js implementation is like defining module 'is', which depends on module 'is'. The factory function ignores the parameter is anyway. The is.js file should start like this (removing the obsolete dependency, removing parameter is and declaring it as a var in line 33): // is.js 0.7.3
// Author: Aras Atasaygin
// AMD with global, Node, or global
;(function(root, factory) {
if(typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(function() {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return root.is = factory();
});
// root.is = factory();
} else if(typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.is = factory();
}
} (this, function() {
// Baseline
/* -------------------------------------------------------------------------- */
var root = this || global;
var previousIs = root.is;
// define 'is' object and current version
var is = {};
is.VERSION = '0.7.3'; |
Same issue here |
@jonrh @jaroslav-muller @sporto Take a look here for a workaround #41 module: {
loaders: [
{ test: /node_modules/, loader: "imports?define=>undefined" }
]
} |
@davidmerrique Thanx! Do you know if there could be any side effects from this workaround by doing this AMD exclusion? |
+1 on this issue |
@jonrh I don't think so, unless you're somehow requiring a package that's only AMD. |
Same issue. @davidmerrique workaround broke me React but this chnages helped me: module: {
loaders: [
{ test: /is_js/, loader: "imports?define=>undefined" }
]
} |
I'm having a building error because of that. :/ define(['is'], function(is) { to define([], function() { |
+1 for me as well. I was able to get this to work also by changing the AMD dependency
|
#100 (comment) > This also worked for me as well |
@arasatasaygin do you have any collaborators that could help you resolve this issue? |
You all seems to be using AMD with Webpack and experiencing this issue. I am using CommonJS (Webpack) and also experiencing it—seems it doesn't belongs only to AMD users. Just registering. :-) |
This is fixed with #138 |
Thanks @arasatasaygin, @ryantemple, and others for your work, excellent job! |
Just came across a weird issue when trying to require is.js when using the module bundler webpack. In JavaScript I do:
When using webpack this causes webpack to freak out and give an error message like this:
I'm not entirely sure where the fault is but I suspect it has something to do with is.js and AMD module loading. Maybe even webpack.
I created a repository with some sample code and documentation to reproduce this issue. Included in the repository is a very hacky way to prevent this issue.
The text was updated successfully, but these errors were encountered: