bundle-loader icon indicating copy to clipboard operation
bundle-loader copied to clipboard

feat: add `require.ensure` error callback

Open jharris4 opened this issue 7 years ago • 20 comments

Adds support for an optional error callback to the bundle-loader.

This work was originally done by @richardscarrott: https://github.com/richardscarrott/require-error-handler-webpack-plugin/blob/master/src/BundleLoader.js.

This PR uses the version created by @richardscarrott with refactoring to reflect changes from the bundle-loader repo since the fork was created.

jharris4 avatar Apr 16 '17 13:04 jharris4

CLA assistant check
All committers have signed the CLA.

jsf-clabot avatar Apr 16 '17 13:04 jsf-clabot

Agreed about the tests. Too bad there weren't any tests to begin with...

The require.ensure with error handling does have tests though, so I think it would be sufficient to just test that the correct syntax of require.ensure is called by bundle-loader (for the various permutations of with/without error callback, and with/without chunk name.)

Are there any webpack loaders with tests like that that I could use as a reference for adding some tests to bundle-loader?

Also, what is webpack-defaults?

jharris4 avatar Apr 17 '17 15:04 jharris4

Also, what is webpack-defaults?

It's a default infrastructure we use for loaders and packages. It comes with opinionated testing setup etc. and allows us to maintain the setup as a dependency (it syncs and migrates project config).

bebraw avatar Apr 17 '17 16:04 bebraw

Should be done after defaults, i'll get the pull request in this evening.

@jharris4 - https://github.com/webpack-contrib/bundle-loader/pull/51 is webpack defaults

joshwiens avatar May 02 '17 03:05 joshwiens

@d3viant0ne Ok, I'm still a little unsure as to how to proceed with creating tests for this package, if that's a hard requirement for getting my PR merged...

If it helps put minds at east, I have been using this code in production for months now with no issues via a fork of bundle-loader which is identical to this PR: https://github.com/jharris4/split-chunk-loader

jharris4 avatar May 02 '17 04:05 jharris4

First and foremost, the pull request for defaults has to land in master which will lay the foundations to actually author tests and landing this with defaults is more about not releasing back to back Major version releases than anything else.

As far as tests for this specific pull request, we need to add tests to cover the existing functionality. If those don't provide a path forward, we can deal with it then.

joshwiens avatar May 02 '17 06:05 joshwiens

Any word on the defaults? Anything I can do to help move this forward and get it merged?

jharris4 avatar Jun 08 '17 11:06 jharris4

@jharris4 Should be on the finishing line, sry for the inconvenience

michael-ciniawsky avatar Jun 08 '17 20:06 michael-ciniawsky

Literally working on it now :)

joshwiens avatar Jun 08 '17 20:06 joshwiens

Hope the next release will coming soon! Currently I just edit line.27 to handle loading errors.

"	}, function(err) { cb(null, err); }, " + chunkNameParam + ");\n",

sdhhqb avatar Aug 09 '17 07:08 sdhhqb

@d3viant0ne Any updates on the status of this? Anything I can do to try and help speed things along?

jharris4 avatar Sep 29 '17 20:09 jharris4

@jharris4 - It's technically done. I'll pick up the latest version of defaults & get the other org maintainers to give it a final once over before it merges.

joshwiens avatar Sep 30 '17 02:09 joshwiens

@d3viant0ne Still curious to see if this is gonna move forward :-)

If it helps to get things moving I can try and do some work to integrate webpack-defaults into the fork of this repo that i'm using (https://github.com/jharris4/split-chunk-loader) to make sure everything works. But I could use some pointers on how to do that... :-)

jharris4 avatar Nov 21 '17 15:11 jharris4

@michael-ciniawsky I made the changes you requested. Dare I hope that you guys might be close to actually merging this? :-)

jharris4 avatar Dec 21 '17 17:12 jharris4

Any intent of merging this?

hampusohlsson avatar Feb 16 '18 02:02 hampusohlsson

@michael-ciniawsky @d3viant0ne

Hi guys, so it has been 11 months since I created this PR! Is there anything I can do to move this forward?

I'm starting to look at upgrading to webpack 4 and hopefully this loader won't require any changes for that...

jharris4 avatar Mar 13 '18 14:03 jharris4

@michael-ciniawsky @d3viant0ne I just merged the changes from version 0.5.6 so the build should be passing again soon.

jharris4 avatar Mar 13 '18 15:03 jharris4

@michael-ciniawsky @d3viant0ne Or not! No idea why the travis builds are failing... Something about the rake command. The command "rake" exited with 1.

jharris4 avatar Mar 13 '18 15:03 jharris4

@michael-ciniawsky @d3viant0ne I just fixed a small issue with the error callback not getting passed the error object in non-lazy mode.

We've been using this in production for months now. Any chance we can get this merged so that I can stop maintaining https://github.com/jharris4/split-chunk-loader ? :-)

jharris4 avatar May 23 '18 14:05 jharris4

I'm using the code from this PR and it's working well. Is there any hope with getting this merged?

maksis avatar Feb 18 '19 18:02 maksis