Coder Social home page Coder Social logo

Comments (14)

schneidmaster avatar schneidmaster commented on July 4, 2024 5

I have found that this works as expected if you also independently require in the file, e.g. an import 'jquery'; somewhere at the top of your bundle (before you import other plugins or whatever needs global jQuery to be available). The "problem" is just that simply having the expose-loader rule in your webpack config does not actually cause jquery to be required in anymore; it just exposes it globally when it is subsequently required in. (I use quotes around "problem" because this seems like it may be an intentional behaviour change in webpack 4 -- I noticed the same change between v3 and v4 with how CommonsChunk/splitGroup modules work.) The inline import syntax works because that's actually putting a require directly into your bundle.

from expose-loader.

eerrecalde avatar eerrecalde commented on July 4, 2024 2

Is this gonna be updated? Because of this I can't upgrade to webpack v4. or any workaround?

@krunalshah68, the workaround I found is to use it inline rather than in the webpack.config. In my case, I have something like this in the entry file:
import "expose-loader?$!jquery"; import "expose-loader?jQuery!jquery"

from expose-loader.

eerrecalde avatar eerrecalde commented on July 4, 2024

Hi, any updates about this?

from expose-loader.

alexander-akait avatar alexander-akait commented on July 4, 2024

@eerrecalde PR welcome

from expose-loader.

eerrecalde avatar eerrecalde commented on July 4, 2024

@evilebottnawi Is that mean "we won't fix it" or "we don't have the time at the moment but we'll eventually fix it / have a look at it"?
Thanks!

from expose-loader.

alexander-akait avatar alexander-akait commented on July 4, 2024

@eerrecalde

we don't have the time at the moment but we'll eventually fix it / have a look at it

from expose-loader.

eerrecalde avatar eerrecalde commented on July 4, 2024

That sounds great 👍 Thanks!

from expose-loader.

RoboBurned avatar RoboBurned commented on July 4, 2024
        module: {
            rules: [
			{
				test: require.resolve('knockout'),
				use: [{
				  loader: 'expose-loader',
				  options: 'ko'
				}]
			},

and

        entry: {
            vendor: ['expose-loader?ko!knockout',

does not work as well.

from expose-loader.

krunalshah68 avatar krunalshah68 commented on July 4, 2024

Is this gonna be updated? Because of this I can't upgrade to webpack v4. or any workaround?

from expose-loader.

krunalshah68 avatar krunalshah68 commented on July 4, 2024

@eerrecalde Thanks for the response.
But the thing is that I'm having a non-spa python flask based website so I want to have it configured in webpack only. Any workaround for this?

from expose-loader.

do-adams avatar do-adams commented on July 4, 2024

I can confirm that this appears to be an issue in my case as well.

I cannot get the alternate webpack.config approach to work with Webpack (v4.29.0) but using the inline loader syntax works great as @eerrecalde mentioned!

from expose-loader.

GummyDonut avatar GummyDonut commented on July 4, 2024

Is there any update on this? I have large amounts of legacy JQuery code and I would like to upgrade to webpack 4 but unfortunately I can't install jQuery globally through webpack and I can't import it in the bundle.js as some of the jquery libraries used do not support webpack when they were written.

For now my alternative is simply to call it in my main index.html as a script tag. Which is okay, but would prefer to use webpack here XD

from expose-loader.

TMUND avatar TMUND commented on July 4, 2024

+1

from expose-loader.

alexander-akait avatar alexander-akait commented on July 4, 2024

Fixed in the master

from expose-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.