vercel / webpack-asset-relocator-loader

Used in ncc while emitting and relocating any asset references
https://npmjs.com/@vercel/webpack-asset-relocator-loader
MIT License
100 stars 33 forks source link

Better esm support #74

Open OmgImAlexis opened 4 years ago

OmgImAlexis commented 4 years ago

I noticed in https://github.com/zeit/webpack-asset-relocator-loader/pull/27 esm support was added but only in the cases of require = require('esm')(module);.

What doesn't seem to be supported is this.

const _require = require('esm')(module);
const myModule = _require('my-module');

@guybedford any chance you could help on this?

OmgImAlexis commented 4 years ago

I haven't checked but I don't believe this supports passing the options object to esm either.

For example:

const options = {};
const _require = require('esm')(module, options);
const myModule = _require('my-module');
OmgImAlexis commented 4 years ago

Wouldn't it make more sense to just look for and replace require('esm') while ignoring the rest?