0.0.2 • Published 6 years ago

babel-plugin-experimental-syntax-dynamic-import v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Experimental syntax dynamic import

plugin of automate default access at dynamic import.

Installation

yarn add babel-plugin-experimental-syntax-dynamic-import

Usage

Real dynamic-import syntax will force the .default, but this plugin will omit it.

// index.js
(async () => {
  var assert = await import("assert");
})();
babel index.js --plugins=experimental-syntax-dynamic-import

becomes:

(async () => {
  var assert = (await import("assert")).default;
})();

If you want to do multiple imports using destructuring objects, this plugin doesn't transform anything.

(async () => {
  var { strictEqual, deepEqual } = await import("assert");
})();

becomes(nothing happens):

(async () => {
  var { strictEqual, deepEqual } = await import("assert");
})();

See also

License

MIT