Skip to content

Avoid unnecessary requires#7

Merged
borisirota merged 1 commit intoborisirota:masterfrom
taylor1791:master
May 29, 2016
Merged

Avoid unnecessary requires#7
borisirota merged 1 commit intoborisirota:masterfrom
taylor1791:master

Conversation

@taylor1791
Copy link
Copy Markdown
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.

Comment thread index.js
}

module.exports = function (fn) {
var fnString = fn.toString();
Copy link
Copy Markdown
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
Copy Markdown
Owner

Thanks ! available in version 1.1.0.

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

@taylor1791
Copy link
Copy Markdown
Contributor Author

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

@yocontra
Copy link
Copy Markdown
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
Copy Markdown
Owner

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

@yocontra
Copy link
Copy Markdown
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
Copy Markdown
Owner

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

@borisirota
Copy link
Copy Markdown
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