You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
This seems to be a pre-built javascript file. #1617
I have seen some issues about this relative to Quill, but interested in the problem more generally.
WARNING in ../~/jasmine-promises/dist/jasmine-promises.js
Critical dependencies:
1:113-120 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ../~/jasmine-promises/dist/jasmine-promises.js 1:113-120
I understand thats its better to let webpack compile the source files as opposed to the distribution files, but how is this supposed to generally work? For example, in almost all of my projects, I use the webpack configuration to set a root for my project to resolve. This was I can specify absolute paths to all my files and move files around trivially with a find-replace-all. I may also have some specific loaders in my configuration to read the text from html files and minify them before passing the string into js through the require statement. I've also had a huge pain getting my sass loader to work just right due to issues with url paths. But my point is that if I were to publish a project and someone were to require the source files rather than a distribution file, then odds are, they will not have the proper configuration for it to work...
Is there a plan or a solution to this?
I think it would be worthwhile to come up with some sort of generic configuration that everyone can use and thus be compatible across the board. Just an idea.
Reacted by Erik Kaplun, Taylor Everding, Jori Lallo, omerts, Glen Cheney, Volkan Özçelik, PendletonJones, Maël Nison, Ivan Babak, Jordan Ilchev and 7 more
If i remember, there was a plugin that would allow a sub-project to define proper loaders and partially add to the webpack config.
It generally seems to be a problem that "sharing" webpack-able code will always require a specifi set of configs.
For now, all you can do is document which loaders the peer needs, or use that plugin. i cant search for it atm, school blocks NPM for no good reason. :/
lol. sounds like your school is really trying to hinder your education ;)
Reacted by Valentyn Stets, Yury Kozyrev, Andrew L., Jon, Aaron Boushley, Emil Valeev, Jeroen Ransijn, Julian Poyourow, amulgarg, Roberto Oliveira and 15 more
So, I just ran into this problem w/ raven-js. We are building a dist/raven.js with Browserify that injects a version string extracted from package.json. I don't want people to load the original source, I want them to load this version. But Webpack complains with this warning.
I find this pretty irritating because many libraries are built and loaded with Webpack just fine without warnings, e.g. jQuery. It appears that Webpack really only complains about Browserify-built libraries. If you don't want to drop this warning, it would be great if there was a way library authors could somehow suppress it.
In the meantime, it appears my only solution is to hardcode the version string into raven-js's original source.
Reacted by Dave Lunny, Andrey Gubanov and Osamah Aldoaiss
Just ran into this warning when depending on js-priority-queue. This project is written in CoffeeScript and uses browserify to generate a pure-JS UMD module. Being able to silence the warning (as I don't think js-priority-queue is at fault) would be great.
IMO, unless / until there is an easy way for Webpack to use the correct config for the library source, this warning is more a nuisance than a help. Trying to build our library source with incompatible configs is not going to make happy users.
@puppybits Aren't both of those solutions for library consumers to eliminate the warning? Why is it the library author's responsibility to teach users about this Webpack quirk?
IMO, this warning should not be generated by default for vendor libraries.
Reacted by Clayton Watts, S Panfilov, Michael Kurze and rotatordisk92
As a library author, you shouldn't even have your users require a bundled script, but let the user's package manager lay out packages instead. Plus, if one included a bundled version, and that included a module that is also already included, you'd bubble up the size of the source.
You only distribute the bundled versions as standalone versions for oldschool usage in html tags, but give the user the actual entrypoint of th elibrary to require.
That's a great idea, but as mentioned in this thread, library authors may use a different configuration, or even an entirely different build tool, making our source files incompatible with the library user's build configuration. Do you have an elegant solution to that problem? If so, I'm all ears...
No hardcoding at all... If you want to use it within webpack, you could also just require your package.json - same should go for Browserify.
functiongetVersion(){// put json-loader in your config, otherwise webpack will complain. Don't know the way for Browserify.returnrequire("./package.json").version:
}
Not elegant, thats why I called it exploiting. But it would definitively work. This exported loader list would only apply the babel loader to the specified file.
There is no way of sharing configurations whatsoever. A plugin could spawn a child-compiler and add the results of that into the parent's module tree...but in one way or another it would feel a bit like a hack too.
Frankly peaking, this is the same situation as platform dependant code in C/C++ - its hard to write platform independent code. That is why you are best off making your code tool-independent...but, the javascript land just has too many of these, so I can see this being hard. But yeah, thats one solution.
@Plestik - Using the loader exclude node_modules only ensures that things in node_modules will not be compiled by a specific loader, however webpack will still attempt to resolve the module and bundle it per its runtime:
To exclude node_modules from webpack's runtime you must use externals with something like #839 (comment):
Through much hardship I've come to the following workflow in most all of my library projects:
I bundle libraries as a last resort since this is in general handled better by the consumer app. If I do bundle a library, I'd bundle it to lib/browser.js and force consumers to import with my-proj/lib/browser. Server side node has no use for bundled libs and in general these bundles are going to cause a lot of problems with different versions of things being used in an app.
I put every bit of source code in my src directory. I often see examples where people have a src directory that they compile to their lib directory and then outside of it in the root of the project they will have source files (index.js, server.js, client.js). This makes no sense to me because it forces you to write varying levels of JavaScript and include babel-register's and other things. If you just stick those files inside your src directory and create a src/lib directory, you can write all ES6+ and compile it all at once. I would love to know a good reason for sticking loose files in the root of a project that you have to write ES5 source for.
src/lib is for universal JS. I compile it with babel directly via "build": "babel src/lib -d lib" in my npm scripts section.
For library projects, I always drop in the following items which lets me run npm start when I'm developing (using npm link from a consuming app). npm run release cleans, builds, publishes a new version and publishes the projects gh-pages site automatically using esdoc.
The only way I've found to be sure that I'm not reincluding extra files and that my library still gets all its dependencies in server and browser environments is to make my libraries export factories that take all their heavy vendor dependencies and return the library. This is not very popular in most libraries but better adheres to inversion of control and will not break everyone's applications when React does something like jump from 0.14.0 to 15.0.0 (whats semver say about jumping 15 versions anyway? 😈 ) and you are hard bundling in the 0.14.0 version and now consumer apps have two copies of React. It may be prone to not locking down a specific version of React or other libraries but you can typically detect that pretty easy and call it out if its a big deal.
src/lib/index.js
exportdefault({ React })=>{if(!React)thrownewError('React is required by my-lib')const{ Component, PropTypes }=ReactconstIS_BROWSER=typeofwindow==='object'if(IS_BROWSER){// BROWSER SPECIFIC STUFF}returnprops=>(<div>My library component</div>)}
This pattern tends to work better for me, the smaller I make my libraries (less dependencies). I will likely switch things up a bit soon with Webpack 2's systemjs chunking support but for now this is what I use across the board, and I work on 15 or so libraries simultaneously (all linked and using babel watch via my npm start script). The added benefit is you get the same benefits as webpack alias by just shoving your bits of application logic into its own module, except you don't need to worry about the whole thing blowing up when imported from a non-webpacked module (webpack isomorphic stuff made me sick to my stomach).
My projects all linked and hot reloading eachother via plain old babel
If there are holes in my logic, please let me know! I'm constantly trying to improve my system generically and apply it horizontally to all my projects so I'd be appreciative for any third-party perspectives.
Reacted by Garret LeCompte, omerts, Dawid Rusnak and Pascal Pflaum
Not to off topic but.. @IAMtheIAM - This is a theme I configured for ConEmu (Windows 10, msys2, zsh) running in quake mode full config here. I often split out modular bits of apps into their own packages, then npm link them into my main app. I then use babel src/lib -d lib --watch on each of them to live rebuild all of them at the same time. Once they are mature I npm install them and make room for new ones.
Reacted by Aaron Frost, Paul Sanchez, Lee Reinhardt, Simone Busoli, Clayton Watts, Paul Korzhyk, Valentin Hăloiu, Stephen Saucier, Kevin Smith, Mat Gessel and 31 more
Reacted by Abdullah Hilson, Shiv Roy, Jesse Gibson, Ben Sperr and Maha Benabbou
Unfortunately this doesn’t solve the problem for Create React App users who have no way to change the configuration. So for them the warnings are entirely non-actionable. I wish there was a way to mute this warning in particular, rather than ignore all warnings (which ideally should fail the CI unlike this one).
Reacted by Dan Levy, German Hernandez, Cory Simmons, Zach Holman, Misha Reyzlin, Graham Swan, Eric Elliott, Tyler Singer-Clark and Yann Lombard
The warning itself is not the problem here. The reason it shows a warning is that the source for the npm should not be ready minified code! Hiding the warning just ignores the problem, it does not fix it! The real problem is that if something fails when running in the browser, the console outputs cryptic errors referencing minified method names and properties in the stack trace. Like "Uncaught TypeError: Cannot read property 'nb' of null at Cb (...) at dc (...) at Object.fc ....." This makes it impossible to know what went wrong, and very hard to debug.
Still didn't understand how to change my library. I use TypeScript. So I need to build a special build for webpack and after this to build another build for the html integration? Too many moves for open source libs...
Activity
IngwiePhoenix commentedon Nov 17, 2015
If i remember, there was a plugin that would allow a sub-project to define proper loaders and partially add to the webpack config.
It generally seems to be a problem that "sharing" webpack-able code will always require a specifi set of configs.
For now, all you can do is document which loaders the peer needs, or use that plugin. i cant search for it atm, school blocks NPM for no good reason. :/
ccorcos commentedon Nov 17, 2015
lol. sounds like your school is really trying to hinder your education ;)
benvinegar commentedon Jan 12, 2016
So, I just ran into this problem w/ raven-js. We are building a
dist/raven.jswith Browserify that injects a version string extracted from package.json. I don't want people to load the original source, I want them to load this version. But Webpack complains with this warning.I find this pretty irritating because many libraries are built and loaded with Webpack just fine without warnings, e.g. jQuery. It appears that Webpack really only complains about Browserify-built libraries. If you don't want to drop this warning, it would be great if there was a way library authors could somehow suppress it.
In the meantime, it appears my only solution is to hardcode the version string into raven-js's original source.
diroussel commentedon Jan 12, 2016
+1 same issue with raven-js here.
dgieselaar commentedon Feb 2, 2016
Any way to at least suppress this warning until the authors get their libraries fixed?
tbroyer commentedon Feb 3, 2016
Just ran into this warning when depending on
js-priority-queue. This project is written in CoffeeScript and uses browserify to generate a pure-JS UMD module. Being able to silence the warning (as I don't thinkjs-priority-queueis at fault) would be great.ericelliott commentedon Feb 9, 2016
IMO, unless / until there is an easy way for Webpack to use the correct config for the library source, this warning is more a nuisance than a help. Trying to build our library source with incompatible configs is not going to make happy users.
puppybits commentedon Feb 9, 2016
Doesn't noParse handle this? Or the resolver plugin to tweak the import when reading the package.json.
ericelliott commentedon Feb 9, 2016
@puppybits Aren't both of those solutions for library consumers to eliminate the warning? Why is it the library author's responsibility to teach users about this Webpack quirk?
IMO, this warning should not be generated by default for vendor libraries.
IngwiePhoenix commentedon Feb 9, 2016
You have it all wrong...
As a library author, you shouldn't even have your users require a bundled script, but let the user's package manager lay out packages instead. Plus, if one included a bundled version, and that included a module that is also already included, you'd bubble up the size of the source.
You only distribute the bundled versions as standalone versions for oldschool usage in html tags, but give the user the actual entrypoint of th elibrary to require.
package.json'smainfield should point toindex.js, whilst when using oldschool script tags, you should use stuff within thedistfolder.Unfortunately, there are quite a lot of projects that dont get this right...
ericelliott commentedon Feb 9, 2016
@IngwiePhoenix
That's a great idea, but as mentioned in this thread, library authors may use a different configuration, or even an entirely different build tool, making our source files incompatible with the library user's build configuration. Do you have an elegant solution to that problem? If so, I'm all ears...
IngwiePhoenix commentedon Feb 9, 2016
@benvinegar Why?
No hardcoding at all... If you want to use it within webpack, you could also just require your
package.json- same should go for Browserify.ericelliott commentedon Feb 9, 2016
@IngwiePhoenix See this comment.
IngwiePhoenix commentedon Feb 9, 2016
@ericelliott You mean if a library wants to make webpack aware of a different set of configurations for the library?
For now, all I could think of is exploiting the loader list.
A loader let's you define things such as
includeandexclude. Usinginclude, you could export:Not elegant, thats why I called it exploiting. But it would definitively work. This exported loader list would only apply the babel loader to the specified file.
There is no way of sharing configurations whatsoever. A plugin could spawn a child-compiler and add the results of that into the parent's module tree...but in one way or another it would feel a bit like a hack too.
Frankly peaking, this is the same situation as platform dependant code in C/C++ - its hard to write platform independent code. That is why you are best off making your code tool-independent...but, the javascript land just has too many of these, so I can see this being hard. But yeah, thats one solution.
3 remaining items
cchamberlain commentedon Apr 29, 2016
@Plestik - Using the loader exclude
node_modulesonly ensures that things in node_modules will not be compiled by a specific loader, however webpack will still attempt to resolve the module and bundle it per its runtime:To exclude
node_modulesfrom webpack's runtime you must use externals with something like #839 (comment):cchamberlain commentedon Apr 29, 2016
@ericelliott @IngwiePhoenix
Through much hardship I've come to the following workflow in most all of my library projects:
lib/browser.jsand force consumers to import withmy-proj/lib/browser. Server side node has no use for bundled libs and in general these bundles are going to cause a lot of problems with different versions of things being used in an app.srcdirectory. I often see examples where people have asrcdirectory that they compile to theirlibdirectory and then outside of it in the root of the project they will have source files (index.js,server.js,client.js). This makes no sense to me because it forces you to write varying levels of JavaScript and include babel-register's and other things. If you just stick those files inside your src directory and create asrc/libdirectory, you can write all ES6+ and compile it all at once. I would love to know a good reason for sticking loose files in the root of a project that you have to write ES5 source for.src/libis for universal JS. I compile it with babel directly via"build": "babel src/lib -d lib"in my npm scripts section.npm startwhen I'm developing (using npm link from a consuming app).npm run releasecleans, builds, publishes a new version and publishes the projects gh-pages site automatically using esdoc.package.json
.gitignore
.npmignore
esdoc.json
{ "source": "./src/lib", "destination": "./doc", "index": "./README.md", "package": "./package.json", "coverage": true, "includeSource": true, "plugins": [ {"name": "esdoc-es7-plugin"} ] }0.14.0to15.0.0(whats semver say about jumping 15 versions anyway? 😈 ) and you are hard bundling in the0.14.0version and now consumer apps have two copies of React. It may be prone to not locking down a specific version of React or other libraries but you can typically detect that pretty easy and call it out if its a big deal.src/lib/index.js
This pattern tends to work better for me, the smaller I make my libraries (less dependencies). I will likely switch things up a bit soon with Webpack 2's systemjs chunking support but for now this is what I use across the board, and I work on 15 or so libraries simultaneously (all linked and using babel watch via my
npm startscript). The added benefit is you get the same benefits as webpack alias by just shoving your bits of application logic into its own module, except you don't need to worry about the whole thing blowing up when imported from a non-webpacked module (webpack isomorphic stuff made me sick to my stomach).My projects all linked and hot reloading eachother via plain old babel

If there are holes in my logic, please let me know! I'm constantly trying to improve my system generically and apply it horizontally to all my projects so I'd be appreciative for any third-party perspectives.
IAMtheIAM commentedon May 26, 2016
@cchamberlain What is that cool multi console screen with the green text? :-) What is the need for seeing 15 console outputs at once anyway?
cchamberlain commentedon May 26, 2016
Not to off topic but..
@IAMtheIAM - This is a theme I configured for ConEmu (Windows 10, msys2, zsh) running in quake mode full config here. I often split out modular bits of apps into their own packages, then
npm linkthem into my main app. I then usebabel src/lib -d lib --watchon each of them to live rebuild all of them at the same time. Once they are mature I npm install them and make room for new ones.mverderese commentedon Jun 3, 2016
To suppress the warning (with quill for example) just add the following to your webpack config:
bebraw commentedon Jan 22, 2017
Closing as a solution (
module.noParse) was presented.gaearon commentedon Feb 11, 2017
Unfortunately this doesn’t solve the problem for Create React App users who have no way to change the configuration. So for them the warnings are entirely non-actionable. I wish there was a way to mute this warning in particular, rather than ignore all warnings (which ideally should fail the CI unlike this one).
bebraw commentedon Feb 11, 2017
@gaearon Can you set up a separate issue for the feature request?
gaearon commentedon Feb 11, 2017
Yea sure.
gaearon commentedon Feb 11, 2017
Filed #4263
Hide warnings for ajv.bundle.js
asmundwego commentedon May 3, 2017
The warning itself is not the problem here. The reason it shows a warning is that the source for the npm should not be ready minified code! Hiding the warning just ignores the problem, it does not fix it! The real problem is that if something fails when running in the browser, the console outputs cryptic errors referencing minified method names and properties in the stack trace. Like "Uncaught TypeError: Cannot read property 'nb' of null at Cb (...) at dc (...) at Object.fc ....." This makes it impossible to know what went wrong, and very hard to debug.
ericelliott commentedon May 4, 2017
@asmundwego minified isn't the same as "pre-built", and AFAIK, this warning is not just for minified bundles.
xr0master commentedon Jun 5, 2018
Still didn't understand how to change my library. I use TypeScript. So I need to build a special build for webpack and after this to build another build for the html integration? Too many moves for open source libs...