Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Prevent chunking out when not in production environment #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jalooc
Copy link

@jalooc jalooc commented Apr 26, 2017

Due to HMR problems with on-demand chunks, I figured it would be nice if the loader loaded the chunks synchronously when in dev environment and as so far in prod. And that's what this commit does.

Other ideas: I was also wondering about adding some additional flag to force async loading in development, but eventually opted-out. Alternatively, sync loading in development could be made an optional (instead of default) behavior. If you find some of the modifications useful, I'd be happy to alter the merge request to suit more needs.

@jsf-clabot
Copy link

jsf-clabot commented Apr 26, 2017

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jalooc I'm not regularly using this loader so I need to get other eyes on this aswell 😛

@@ -19,7 +19,9 @@ module.exports.pitch = function(remainingRequest) {
var chunkNameParam = '';
}
var result;
if(query.lazy) {
if(process.env.NODE_ENV !== 'production') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to introduce an option here, NODE_ENV === 'production' is common, but no real standard

@jalooc
Copy link
Author

jalooc commented Apr 28, 2017

I was also wandering about adding an option (just another env var) forcing synchronous load, which could be potentially useful in static page rendering e.g. for ssr or bots. Do you think it's a good idea?

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Apr 28, 2017

@jalooc If you are not enterily pissed of in case we maybe need to revert a few things afterwards, then please go ahead and we will see if it is something we should add or not 😛

I was also wandering about adding an option (just another env var)

Just and option (query), eg require(bundle-loader?sync&name=[name]!./file.bundle.js)
Could you also try if webpacj 2 snytax and setting the loader up in webpack.config.js basically works ? 🙃

entry.js

import bundle from './name.bundle.js'

webpack.config.js

{
   test: /\.bundle\.js$/,
   use: { loader: 'bundle-loader', options: { name: '[name]' } }
},
{
   test: /\bundle\.async\.js$/,
   use: { loader: 'bundle-loader', options: { lazy: true, name: '[name]' } }
}

etc 😛

Maybe if we add a sync option, we should rename lazy => async and cut a major release together with #48 what do you think 🙃 ?

@joshwiens
Copy link
Member

@michael-ciniawsky
Copy link
Member

kk, so sync doesn't make any sense at all ? I was wondering about it, but not 💯 since i'm not using this loader extensively. If so we better close the PR :)

@jalooc
Copy link
Author

jalooc commented May 7, 2017

@michael-ciniawsky I'm not sure if I fully understand your point. The suggested in this PR ability for skipping chunking-out (I called it sync loading before, but maybe it was confusing) is just for development purposes, so files naming convention wouldn't be right for this application. I also don't think it's related with #51.

@michael-ciniawsky michael-ciniawsky removed their assignment Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants