Repository navigation
Packaging issues after node-jquery update #54
Copy link
Copy link
Closed
Description
Hi sokra,
I just got involved in another JS project and decided to stick with the tools I am familiar with, i.e. webpack, among others. Unfortunately when I created a new project I ran into some strange errors I could not explain. I ended up cleaning my old project of all generated content (npm & jam modules) and updated the dependencies. Now with node-jquery 1.8.3 my old project won't build at all. When I try to webpack the following minimal example
// main.js
'use strict';
/*global require:true */
require = require('enhanced-require')(module, {
recursive: true
});
var $ = require('jquery');
I get the following warnings:
WARNING: A file in context was excluded because of error: Error: File "<project root>\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level1\core.js" parsing failed: Error: Line 418: Unexpected token )
WARNING: A file in context was excluded because of error: Error: File "<project root>\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level2\html.js" parsing failed: Error: Line 446: Unexpected token )
WARNING: Cannot find module 'node-htmlparser/lib/node-htmlparser'
Error: Module "node-htmlparser/lib/node-htmlparser" not found in context "<project root>\node_modules\jquery\node
_modules\jsdom\lib\jsdom\browser"
Error: <project root>\node_modules\webpack\buildin\node-htmlparser\lib\node-htmlparser is not a directory
@ <project root>\node_modules\jquery\node_modules\jsdom\lib\jsdom\browser\index.js (line 336, column 24)
WARNING: Cannot find module 'tls'
Error: Module "tls" not found in context "<project root>\node_modules\jquery\node_modules\jsdom\node_modules\requ
est"
Error: Non of this files exists: <project root>\node_modules\webpack\buildin\tls-webpack, <project root>
\node_modules\webpack\buildin\tls-webpack.webpack.js, <project root>
\node_modules\webpack\buildin\tls-webpack.web.js, <project root>\node_modules\webpack\buildin\tls-webpack.js
@ <project root>\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 44, column 8)
WARNING: A file in context was excluded because of error: Error: File "<project root>\node_modules\jquery\node_mod
ules\contextify\node_modules\bindings\README.md" parsing failed: Error: Line 2: Unexpected token ===
WARNING: Cannot find module 'https'
Error: Module "https" not found in context "<project root>\node_modules\jquery\node_modules\jsdom\node_modules\re
quest"
Error: Non of this files exists: <project root>\node_modules\webpack\buildin\https, <project root>
\node_modules\webpack\buildin\https.webpack.js, <project root>\node_module
s\webpack\buildin\https.web.js, <project root>\node_modules\webpack\buildin\https.js
@ <project root>\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 40, column 10)
plus a ton of errors like:
ERROR: Cannot find module '../../../lib/numeric'
Error: Error: Module "jshint" not found in context "<project root>\src\client\numeric"
Error: <project root>\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
@ <project root>\src\client\numeric\LinearSolver.js (line 7, column 36)
ERROR: Cannot find module '../../../../lib/spin'
Error: Error: Module "jshint" not found in context "<project root>\src\client\view\recipe"
Error: <project root>\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
@ <project root>\src\client\view\recipe\RecipeListView.js (line 9, column 11)
ERROR: Cannot find module 'fs'
Error: Module "fs" not found in context "<project root>\node_modules\jquery\node_modules\xmlhttprequest\lib"
Error: <project root>\node_modules\webpack\buildin\fs is not a directory
@ <project root>\node_modules\jquery\node_modules\xmlhttprequest\lib\XMLHttpRequest.js (line 16, column 9)
For this example I npm installed the latest versions of jquery, webpack, enhanced-require (node_modules) and jam installed jquery (web_modules). Do you happen to have an idea of what went wrong here?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
miffels commentedon Jan 20, 2013
I just played around a bit more and got the following results:
webpack 0.8.xplays nicely withenhanced-require 0.4.x,node-jquery 1.7.xand (jam)jquery 1.7.x. Updatingnode-jqueryto the latest version (1.8.3) did not change anything (i.e. it still built flawlessly). When I did the same withjam'sjquery, though, the above errors reoccured (tried1.9.0preand1.8.3). I actually suspectednode-jqueryto cause the errors, so that outcome sort of surprised me.sokra commentedon Jan 21, 2013
hmm.. i think the problem is that webpack do not respect the jam section in the package.json
So it tries to load
index.jswhich doesn't exist. So it triesnode-jquerywith mixed in jam'sjquery... fail...I'll add support for jam.main as
packageMains.jam writes a config for require.js which includes the main field. So require.js would work.
Add support for nested packageMains. pass an array. webpack/webpack#54
sokra commentedon Jan 21, 2013
So I added
jam.mainto the defaults for packageMains.Your example will build now:
miffels commentedon Jan 22, 2013
Hi sokra,
I just tried it in one of my projects and can confirm this works flawlessly. Thank you very much!
Best regards,
miffels
sokra commentedon Jan 22, 2013
😄
fixes webpack#54