Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Webpack jQuery dependency #10

Closed
rachidio opened this issue Jan 6, 2018 · 4 comments
Closed

Webpack jQuery dependency #10

rachidio opened this issue Jan 6, 2018 · 4 comments
Assignees
Labels
integration integration with other angular, node, webpack, etc.

Comments

@rachidio
Copy link

rachidio commented Jan 6, 2018

Hello,
When I am building my application based on sprLib, with npm and webpack, the file included in the build is sprestlib.js which does not contains the Jquery dependency.
import sprLib from 'sprestlib' is including this file instead of sprestlib.bundle.js which contains the jquery dependency.
To bypass this I modified the file sprestlib/package.json:

"main": "dist/sprestlib.js", --> "main": "dist/sprestlib.bundle.js",

Is this the expected behavior? Do I misunderstood something?
Why don't replace Jquery by a more specific library such as axios, lodash, etc...?

Thank you

@Dragnucs
Copy link

Dragnucs commented Jan 6, 2018

Simply importing a module wont bring jQuery even if the module depends on it. You still need to explicitly import it like so:

const $ = require('jquery')
// Or
import jQuery from 'jquery'

Or, you can shim the module using ProvidePlugin so it is present everywhere. This way is probably better suited for jQuery because it would allow you to map both $ and jQuery to the same instance of jQuery.

@rachidio
Copy link
Author

rachidio commented Jan 7, 2018

First part is resolved :)

@gitbrent what about?

Why don't replace Jquery by a more specific library such as axios, lodash, etc...?

@Dragnucs
Copy link

Dragnucs commented Jan 7, 2018

Replacing jQuery infavor of axios is a good decision.

Maybe we should make a PR for this, shouldn't we @ra6hi9?

@gitbrent
Copy link
Owner

gitbrent commented Jan 8, 2018

Hi Guys,

@ra6hi9: the package.json file lists "jquery-node" and the library calls var $ = require("jquery-node");, so I don't know why you'd be having this issue with webpack. Wouldn't it use produce a product similar to node?

@Dragnucs: i'm working to move the UI functions to a separate library, so jQuery shouldn't need to be around long. I'd rather have no dependencies. :)

@gitbrent gitbrent self-assigned this Jan 8, 2018
@gitbrent gitbrent changed the title Jquery dependency Webpack jQuery dependency Jan 8, 2018
@gitbrent gitbrent added the integration integration with other angular, node, webpack, etc. label Jan 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
integration integration with other angular, node, webpack, etc.
Projects
None yet
Development

No branches or pull requests

3 participants