Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Commit a4110cc

Browse files
committed
support esm plugins
1 parent dbe02a0 commit a4110cc

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

plugin-babel.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,18 @@ exports.translate = function(load) {
9191

9292
if (babelOptions.plugins)
9393
babelOptions.plugins.forEach(function(plugin) {
94-
if (typeof plugin == 'string')
95-
pluginAndPresetModuleLoads.push(pluginLoader['import'](plugin, module.id));
96-
else if (Array.isArray(plugin) && typeof plugin[0] == 'string')
97-
pluginAndPresetModuleLoads.push(pluginLoader['import'](plugin[0], module.id));
94+
plugin = typeof plugin == 'string' ? plugin : Array.isArray(plugin) && typeof plugin[0] == 'string' && plugin[0];
95+
if (!plugin)
96+
return;
97+
pluginAndPresetModuleLoads.push(
98+
pluginLoader.normalize(plugin, module.id)
99+
.then(function(normalized) {
100+
return pluginLoader.load(normalized)
101+
.then(function() {
102+
return pluginLoader.get(normalized)['default'];
103+
});
104+
});
105+
);
98106
});
99107

100108
return Promise.all(pluginAndPresetModuleLoads)

0 commit comments

Comments
 (0)