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

Problems with require.cache #16

Closed
jhnns opened this issue Aug 14, 2012 · 4 comments
Closed

Problems with require.cache #16

jhnns opened this issue Aug 14, 2012 · 4 comments

Comments

@jhnns
Copy link
Member

jhnns commented Aug 14, 2012

Since version 0.5.10 webpack requires every loader in a new "context" by removing all modules from cache and readding them after the loader has been executed.

I think it's very delicate to mess around with require.cache because this can lead to totally unexpected behavior. Is there are an important reason why you've introduced this?

Currently I have to lock webpack at version 0.5.8 because it breaks my code.

@sokra
Copy link
Member

sokra commented Aug 14, 2012

I've done this because it failed reloading loaders when in watch mode and a loader has changed.

It can fail if you rely on require in a loader return the same instance as a require not in a loader.

Multi process compiling is on roadmap and this will make these loaders fail too.

Why exactly do your code fail?

You can stay locked at 0.5.8 until we have a solution. I'm on vacation for a week by now, sorry.

@jhnns
Copy link
Member Author

jhnns commented Aug 14, 2012

My module nodeclass takes so-called descriptor-objects and creates a class function. Defining a class looks like:

var MyClass = new Class("MyClass", {
    Extends: require("./MySuperClass.class.js"),
    init: function () {}
});

In order to compute all inherited properties I have to save every descriptor in a registry. Now the registry can't save those descriptors because it is created from scratch for every new class.

I think it's ok that webpack needs to be restarted if a loader has changed. Changing a loader is not the same like changing a module that will be bundled.

Currently webpack removes the whole cache before every single file. This is almost like starting a new process for every file.

@sokra
Copy link
Member

sokra commented Aug 14, 2012

Hmm.. i should undo this change and make multi process building as opt-in (per loader) feature. Webpack should throw an warning or an error if a loader is changed.

@jhnns
Copy link
Member Author

jhnns commented Aug 14, 2012

I'm glad that I could convince you 😆

@sokra sokra closed this as completed in c912c01 Aug 23, 2012
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

No branches or pull requests

2 participants