Skip to content

Watch mode #50

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

Closed
markuplab opened this issue Nov 27, 2015 · 11 comments
Closed

Watch mode #50

markuplab opened this issue Nov 27, 2015 · 11 comments

Comments

@markuplab
Copy link

CSS map changes doesn't apply, if module was changed.
It's due all modules in node js exposed as cached objects.
All reference saved in require.cache.

This tiny helper, that we use for clear require.cache:

  /**
   * Clears node.js require cache by key.
   * @param {string} key Cache key.
   */
  function clearCacheKey (key) {
    delete require.cache[key];
  }
@mightyaleksey
Copy link
Member

Yeah, that's true. Node.js caches all the require calls by default.
I assume you use this feature for the development needs only.

I think, I can add a check for the environment variable NODE_ENV and if it's equal to development, then clean cache from the require calls. Something similar to this: https://github.com/reactjs/express-react-views/blob/master/index.js#L59-L66

@markuplab
Copy link
Author

Yes, it's for development workaround. env var is good idea.

@markuplab
Copy link
Author

@sullenor When you can fix it?

@mightyaleksey
Copy link
Member

@markuplab I'll try tomorrow

@mightyaleksey
Copy link
Member

done, 2.1.0

@yazonnile
Copy link
Contributor

Hey, everybody.
Thx, for great module!

I have some minor problem. Actually it`s not a problem at the moment, but think it could make some in future.

I'm talking about this https://github.com/reactjs/express-react-views/blob/master/index.js#L59-L66
Think NODE_ENV = "development" is very wide thing. And I would prefer something like this

var initHooks = require('css-modules-require-hook');
initHooks({
    generateScopedName: generateScopedName(config),
    extensions: config.extensions.styles,
    preprocessCss,
    processCss,
    debug: true // <------------------
});

to make cache cleaning sort of isolated. Just for that module. Without any influence to some other.
And this debug: true will make all that things that now are made by NODE_ENV="development"

Is that possible?

@yazonnile
Copy link
Contributor

#56 add pr

@mightyaleksey
Copy link
Member

Looks like you have a slightly different name of the option in the pr (devMode) :)

I don't mind to have a stronger option to control environment and I think its a good enhancement.

Sorry for the late response, I'll make the new version soon.

@yazonnile
Copy link
Contributor

oops, my bad :)

I'll make the new version soon.

Wait for it. Good luck!

@mightyaleksey
Copy link
Member

@yazonnile should be available for now. Check out 2.1.1

Thank you :)

@yazonnile
Copy link
Contributor

Great! Welcome)!

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

3 participants