Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Non-js imports are not to be watched #23

Closed
droooney opened this issue Sep 27, 2016 · 5 comments
Closed

Non-js imports are not to be watched #23

droooney opened this issue Sep 27, 2016 · 5 comments

Comments

@droooney
Copy link

I've noticed this issue working with pug and less plugins. @import's in less and include's in pug don't seem to be watched. If I change any of the less or pug files that are directly imported in js file the watch process reflects but once I change some less file I import in this less file (or include a pug file) the watch process doesn't seem to react in any way. For example:

// mixins.less

.hidden {
  display: none;
}



// main.less

@import './mixins';

body {
  .hidden();
}

or in pug:

//- mixins.pug

mixin input(name)
  input(name=name)



//- main.pug

include ./mixins

form
  +input('email')

When you have a lot of mixins it's pretty annoying and watching files using rollup-watch doesn't seem to be very useful. Can this even be solved?

@tivac
Copy link
Contributor

tivac commented Sep 27, 2016

That's something the plugins should handle. modular-css handles this by injecting a bunch of import statements into the JS. Rollup will correctly follow them and then watch those files, but they get tree-shaken out since nothing ever references them.

https://github.com/tivac/modular-css/blob/master/src/rollup.js#L48-L71

@droooney
Copy link
Author

So there is no way to use tree-shaking and count on watching non-js files even if plugins were importing partials/includes/imports etc the way modular-css does?

@tivac
Copy link
Contributor

tivac commented Sep 28, 2016

Tree-shaking only works on JS code. If your non-JS is being transformed by a plugin into JS then it will have tree-shaking applied.

If the non-JS has it's own dependencies it'll be up to the plugin to transform those into ES2015-style dependencies using import if you want the non-JS files to be watched.

@droooney
Copy link
Author

Well, I totally get that tree-shaking works on JS code only. But that doesn't make any sense to transform non-JS code into the ES6 modules only to get them tree-shaken. So that's the question: can I achieve both watching non-JS deps and (if they are transformed into JS files) not getting them tree-shaken?

@Rich-Harris
Copy link
Contributor

Closing in favour of rollup/rollup#1203

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

No branches or pull requests

3 participants