The `externalRuntime` optional transformer can be used in conjunction with the `runtime` option to import and use the runtime from a module instead of polluting the global environment.
12 lines
413 B
JavaScript
12 lines
413 B
JavaScript
exports.optional = true;
|
|
|
|
// In theory, it would be more appropriate to do this in `manipulateOptions`,
|
|
// but we need an identifier for the import and we can't get that before the
|
|
// AST is built.
|
|
exports.ast = {
|
|
enter: function (ast, file) {
|
|
file.opts.runtime = file.addImport(file.opts.runtime, "to5Runtime").name;
|
|
file.dynamicImports[file.dynamicImports.length - 1]._noInteropRequire = true;
|
|
}
|
|
};
|