esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Failed to import - @putout/plugin-putout?alias=putout:@putout/bundle

Open coderaiser opened this issue 3 years ago • 0 comments

Failing module

  • GitHub: https://github.com/coderaiser/putout
  • npm: putout
import pluginPutout from 'https://esm.sh/@putout/plugin-putout?alias=putout:@putout/bundle';

Error message

After onload I got this:

Uncaught (in promise) Error: Dynamic require of "./apply-processors-destructuring" is not supported

Additional info

  • esm.sh version: v87
  • Browser version: Chrome v105

Would be great to have ability to support constructions like this:

const getRule = (a) => ({
    [a]: require(`./${a}`),
});

module.exports.rules = {
    ...getRule('apply-async-formatter'),
};

Of course I can switch to:

const applyAsyncFormatter = require('./apply-async-formatter');

module.exports.rules = {
    'apply-async-formatter': applyAsyncFormatter,
};

But that's much more code, repetition, and places to update when I'm adding a new rule. Webpack handles such cases easily, is it possible to add support of it to esm.sh somehow?

coderaiser avatar Jul 13 '22 13:07 coderaiser