Skip to content

webpack error when requiring jam jquery #39

Closed

Description

@kavaro

Hi @sokra

When I try to require('jquery'), which is a jam module installed under web_modules, I always get the following message:

- Serving static content.
- dev-server on port 8081.
> Open http://localhost:8081/ in your browser.


Error: watch ENOENT
    at errnoException (fs.js:806:11)
    at FSWatcher.start (fs.js:837:11)
    at Object.fs.watch (fs.js:861:11)
    at module.exports (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:223:23)
    at Array.forEach (native)
    at EventEmitter.<anonymous> (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:222:19)
    at EventEmitter.emit (events.js:123:20)
    at writingFinished (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:522:19)
    at /Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:379:30
    at buildTree (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/buildDeps.js:103:3)
Hash: 4732db73d220259503822d5a079cf898
Compile Time: 677ms
Chunks: 1
Modules: 6
Modules including duplicates: 6
Modules first chunk: 6

 <id>    <size>  <filename>
dev.bundle.js
    0        11  ./_template/entry.js [caching]
    1        45  ./app/app.js [caching]
    2    259828  ./app/web_modules/jquery/jquery.js [caching]
    3       533  (webpack)/buildin/__webpack_amd_define.js [caching]
    4       428  (webpack)/buildin/__webpack_amd_require.js [caching]
    5        24  (webpack)/buildin/__webpack_options_amd.loader.js!(webpack)/buildin/__webpack_options_amd.loader.js [caching]
webpack: bundle is now VALID.

Jquery seems to be correctly bundled in the app and the server also works, but, I always get an error message related to watch and I am not sure whether it is save to ignore this message !!! For sure the message should not be there :-)

My setup as as follows:

wpt create jam-app
cd jam-app
npm install

Now add jam-dependencies to package.json

    "jam": {
        "packageDir": "app/web_modules",
        "baseUrl": "app",
        "dependencies": {
            "jquery": "1.8.0",
            "bootstrap": "2.1.1-jam.1"
        }
    },

Then run:

jam install
dev-server.sh

And now the error messages start to appear

Activity

  1. kavaro commented on Nov 9, 2012

    @kavaro
    Author

    Forgot to mention that you (obviously) need to require('jquery') in app.js
    Without the require there is no Error message.

  2. kavaro commented on Nov 9, 2012

    @kavaro
    Author

    FYI: The problem seems to be solved when I change line 506 in file webpack/lib/webpack.js
    from:

    loaders[loader] = true;
    

    to

    loaders[loader.path] = true;
    
  3. added a commit that references this issue on Nov 10, 2012
  4. sokra commented on Nov 10, 2012

    @sokra
    Member

    thx for your investigation. It really helped me to locate to bug.

    It's not safe to ignore the error, because I think watching will not work (correctly).


    for jquery with wpt there is also a wtp-module you can install with wpt install webpack/jquery-wtp-module

  5. kavaro commented on Nov 10, 2012

    @kavaro
    Author

    Thanks, its my pleasure, and, thank you for the quick response time ...

    Just checked and can confirm that bug is solved ...

    Tried the jquery-wtp-module, it is working well and will use it. Same for the bootstrap one.

    On the other hand, I will need quite a few other client side libraries like knockout, crossroads, ...

    The cleanest would probably be to create wpt modules, make sure all these libraries don't pollute the global namespace and return the correct value from the require call (which the jam jquery for example does not), but,
    on the other hand this would be more effort. (Actually I am wonder that maybe wpt modules could be generated
    automatically based on the jam package + a few options)

    @kavaro

  6. sokra commented on Nov 11, 2012

    @sokra
    Member

    I don't think converting jam modules to wpt-modules is a good idea.

    • The most jam modules will work with webpack.
    • Multiple registries are bad.
    • Most client side libaries only need a few lines big wrapper to work.

    wpt modules are good to deeply integrate stuff into the template (like the bootstrap wpt module, with config files, webpack options etc.

    For simple module purposes npm and jam will do the stuff.

    Module directories in wpt:

    /node_modules - npm installed modules (config in package.json)
    /web_modules - jam installed modules (config in package.json)
    /app/node_modules - own server side modules
    /app/modules - own shared modules
    /app/web_modules - own client side modules
    
  7. kavaro commented on Nov 11, 2012

    @kavaro
    Author

    Makes sense.

    Thanks for the tip on the directories, was not aware of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions