feats / babel-plugin-inline-import

inline the raw content of import statements
https://www.npmjs.com/package/babel-plugin-inline-import
MIT License
243 stars 29 forks source link

Generate comment with original module name next to inlined module, e.g. for webpack watching & rebuilding #10

Closed elliottsj closed 7 years ago

elliottsj commented 7 years ago

With these changes, a comment is generated before the inlined module to allow other tools to find out the original module name.

For example, webpack can use this to mark the original modules as dependencies for watching those files and rebuilding when the content changes. I've made a webpack loader which does exactly that: https://github.com/elliottsj/babel-inline-import-loader

That loader depends on these changes in order to work; I'd love to get some opinions on this approach.

I've also changed the npm script from "prepublish" to "prepare" so that the script is run when installing the package from git (made testing a bit easier). I can remove this or put it in another PR if you like.

zvictor commented 7 years ago

it is beautiful, thanks!