Skip to content
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

Packaging issues after node-jquery update #54

Closed
miffels opened this issue Jan 20, 2013 · 5 comments
Closed

Packaging issues after node-jquery update #54

miffels opened this issue Jan 20, 2013 · 5 comments

Comments

@miffels
Copy link

miffels commented Jan 20, 2013

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?

@miffels
Copy link
Author

miffels commented Jan 20, 2013

I just played around a bit more and got the following results:

webpack 0.8.x plays nicely with enhanced-require 0.4.x, node-jquery 1.7.x and (jam) jquery 1.7.x. Updating node-jquery to the latest version (1.8.3) did not change anything (i.e. it still built flawlessly). When I did the same with jam's jquery, though, the above errors reoccured (tried 1.9.0pre and 1.8.3). I actually suspected node-jquery to cause the errors, so that outcome sort of surprised me.

@sokra
Copy link
Member

sokra commented Jan 21, 2013

hmm.. i think the problem is that webpack do not respect the jam section in the package.json

  "jam": {
    "main": "dist/jquery.js",
    "include": ["dist/jquery.js"]
  }

So it tries to load index.js which doesn't exist. So it tries node-jquery with mixed in jam's jquery... 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.

sokra added a commit to webpack/enhanced-resolve that referenced this issue Jan 21, 2013
@sokra sokra closed this as completed in e42701d Jan 21, 2013
@sokra
Copy link
Member

sokra commented Jan 21, 2013

So I added jam.main to the defaults for packageMains.

Your example will build now:

Hash: 434aa3aa5292c1b194270b7b7657b191
Compile Time: 554ms
Chunks: 1
Modules: 7
Modules including duplicates: 7
Modules first chunk: 7
main   bundle.js:   272884 chars/bytes

 <id>    <size>  <filename>
bundle.js
    0       134  .\main.js
    1       445  (webpack)\buildin\__webpack_amd_require.js
    2       552  (webpack)\buildin\__webpack_amd_define.js
    3       251  (webpack)\buildin\__webpack_module.js
    4        24  (webpack)\buildin\__webpack_options_amd.loader.js!(webpack)\buildin\__webpack_options_amd.loader.js
    5       151  (webpack)\~\enhanced-require\lib\require.webpack.js
    6    269754  .\web_modules\jquery\dist\jquery.js

@miffels
Copy link
Author

miffels commented 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
Copy link
Member

sokra commented Jan 22, 2013

😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants