Would it be possible (or preferable) to automatically prepend "/web_modules" onto each import statement?
Sure! We'd need to decide what's automatically doing the prepending, Babel?
Actually, it looks like this could work: https://www.npmjs.com/package/babel-plugin-bare-import-rewrite
{
"plugins": [
["bare-import-rewrite", {
"modulesDir": "/web_modules",
"alwaysRootImport": ["**"]
}]
]
}
Trying it out in a project now
How would that work when using both node_moduoes and web_modules?
Okay I tried out every babel plugin I could and no luck. I think we may just want to write one ourselves.
Done! If you install @pika/web v0.2.0 (latest) you can load it into your babelrc like so:
{
"plugins": [
["@pika/web/assets/babel-plugin.js"]
]
}
Still experimental, and might split it out into it's own package before v1, but that gets you want you need!
README updated as well
Awesome! What's the behavior if there's a conflict between node_modules and web_modules?
The plugin is super dumb for now, it just rewrites every "bare name" package import to it's web_modules/ file equivalent ¯\_(ツ)_/¯
Most helpful comment
Done! If you install @pika/web v0.2.0 (latest) you can load it into your babelrc like so:
Still experimental, and might split it out into it's own package before v1, but that gets you want you need!