Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary requires #7

Merged
merged 1 commit into from
May 29, 2016
Merged

Avoid unnecessary requires #7

merged 1 commit into from
May 29, 2016

Conversation

taylor1791
Copy link
Contributor

We encountered a problem with webworkify-webpack. By requireing every module, it is forcing all modules to be initialized. Some of our modules have assumptions about when they are initialized. In particular, they have to be initialized after we use something that uses webworkify-webpack as a dependency.

To fix this, I purpose that we avoid requireing the modules by doing a simple check to see if the module "looks like" the right one. Making wrapperFuncString.indexOf(fnString) > -1 a necessary condition for the require address this issue. The subsequent logic is updated to behave appropriately since the conditions are now reversed.

This fixes the problem and does not change existing behavior as far as I know. This can be considered a breaking change. However, it is one that reverts the behavior to what I and most users expect.

@@ -24,24 +24,29 @@ var webpackBootstrapFunc = function(modules) {
}

module.exports = function (fn) {
var fnString = fn.toString();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this line because it avoids stringifying the function numerous times.

@taylor1791 taylor1791 mentioned this pull request May 21, 2016
@borisirota borisirota merged commit f2a4a4f into borisirota:master May 29, 2016
@borisirota
Copy link
Owner

Thanks ! available in version 1.1.0.

Please take a look at the caveat I added to the README.

@taylor1791
Copy link
Contributor Author

Ah! Good thinking about the caveat. I forgot about that option in webpack.

@yocontra
Copy link
Contributor

Is there any way to get around this? Builds are now 60+ seconds when they used to be 400ms because of this :(

@borisirota
Copy link
Owner

@contra please give more info. webworkify-webpack is a runtime worker builder. It shouldn't affect the webpack build.

@yocontra
Copy link
Contributor

yocontra commented Aug 1, 2016

@borisirota You can't use efficient sourcemaps after this was merged, there's a note in the README about it. It does affect webpack build perf by placing that limitation on anyone who uses it.

@borisirota
Copy link
Owner

@contra you are right and you can get around this by using v1.0.6.

@borisirota
Copy link
Owner

@contra in the new v2 there is no limitation on the devtool options (eval can be used as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants