babel-plugin-transform-assets icon indicating copy to clipboard operation
babel-plugin-transform-assets copied to clipboard

Fix importing files from within dependencies (e.g. in node_modules)

Open inversion opened this issue 6 years ago • 6 comments

Use require.resolve with paths to fix importing files from within dependencies (e.g. in node_modules)

inversion avatar Jul 13 '18 10:07 inversion

Thanks! Can you get rid of the update to node engine?

#7 should fix that for everyone that uses even an older version of node.

jmurzy avatar Jul 15 '18 19:07 jmurzy

require.resolve paths option isn't available until 8.9 which is why I changed the engine

inversion avatar Jul 16 '18 08:07 inversion

Current LTS is 8.11.3. And other people seem to still be using even older versions. So not sure how to best achieve this without having to bump up the engine version. We could probably check node version at runtime and fallback to path.resolve for older versions. What do you think?

jmurzy avatar Jul 16 '18 18:07 jmurzy

8.11.3 is after 8.9 though - are you suggesting that if we do bump the engine version it should be to 8.11.3?

It might be best to do a major release of the plugin with the engine bump so people can continue to use the old version if they can't upgrade Node?

inversion avatar Jul 17 '18 14:07 inversion

We could do a fallback as you suggest but I'm concerned people will continue to use old versions of Node without awareness of this caveat.

Perhaps it might be best to do a major release with the change and deprecate the old versions on NPM?

inversion avatar Jul 17 '18 14:07 inversion

I was suggesting we check if nodeVersion >= 8.9 at runtime and use require.resolve with fallback to resolve on older versions to keep it backward compatible. Something like:

let r = nodeVersion >= '8.9' ? require.resolve : resolve;

But yeah, let's do a v2 release so people who rely on older node can continue using v1.

jmurzy avatar Jul 20 '18 19:07 jmurzy