From 445887e571a0d8ee8bc1db558ee73f22f5f6ba17 Mon Sep 17 00:00:00 2001 From: Gunnar Gabrielson Date: Wed, 11 Mar 2020 17:03:23 -0600 Subject: [PATCH 1/4] Fix typo, added to versioned docs --- docs/plugin-syntax-dynamic-import.md | 11 +++++++++++ .../version-6.26.3/plugin-syntax-dynamic-import.md | 10 ++++++++++ .../version-7.0.0/plugin-syntax-dynamic-import.md | 10 ++++++++++ .../version-7.4.0/plugin-syntax-dynamic-import.md | 10 ++++++++++ 4 files changed, 41 insertions(+) diff --git a/docs/plugin-syntax-dynamic-import.md b/docs/plugin-syntax-dynamic-import.md index 1dd1834313..c966656f1f 100644 --- a/docs/plugin-syntax-dynamic-import.md +++ b/docs/plugin-syntax-dynamic-import.md @@ -4,6 +4,17 @@ title: @babel/plugin-syntax-dynamic-import sidebar_label: syntax-dynamic-import --- +`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). + +In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. + +If you want to transpile import(): + +1. If you are using `@babel/preset-env`, it's automatically handled +2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you +3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` + + ## Installation ```sh diff --git a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md index 12da68e7c3..32a31e87c7 100644 --- a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md @@ -5,6 +5,16 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- +`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). + +In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. + +If you want to transpile import(): + +1. If you are using `@babel/preset-env`, it's automatically handled +2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you +3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` + ## Installation ```sh diff --git a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md index 369dee4966..d417a6ce56 100644 --- a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md @@ -5,6 +5,16 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- +`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). + +In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. + +If you want to transpile import(): + +1. If you are using `@babel/preset-env`, it's automatically handled +2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you +3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` + ## Installation ```sh diff --git a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md index f5e011ab1d..eb8ccf872e 100644 --- a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md @@ -5,6 +5,16 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- +`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). + +In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. + +If you want to transpile import(): + +1. If you are using `@babel/preset-env`, it's automatically handled +2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you +3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` + ## Installation ```sh From 82085c16005469bdfabf5e3c48929bbb6e437d81 Mon Sep 17 00:00:00 2001 From: Gunnar Gabrielson Date: Wed, 11 Mar 2020 17:09:56 -0600 Subject: [PATCH 2/4] fix missing word --- docs/plugin-syntax-dynamic-import.md | 2 +- .../version-6.26.3/plugin-syntax-dynamic-import.md | 2 +- .../version-7.0.0/plugin-syntax-dynamic-import.md | 2 +- .../version-7.4.0/plugin-syntax-dynamic-import.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/plugin-syntax-dynamic-import.md b/docs/plugin-syntax-dynamic-import.md index c966656f1f..dc6454428e 100644 --- a/docs/plugin-syntax-dynamic-import.md +++ b/docs/plugin-syntax-dynamic-import.md @@ -4,7 +4,7 @@ title: @babel/plugin-syntax-dynamic-import sidebar_label: syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. diff --git a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md index 32a31e87c7..cfc0f7238f 100644 --- a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md @@ -5,7 +5,7 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. diff --git a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md index d417a6ce56..ce9fab3e57 100644 --- a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md @@ -5,7 +5,7 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. diff --git a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md index eb8ccf872e..4dd5291c56 100644 --- a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md @@ -5,7 +5,7 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` needed to enable parsing for import(). +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. From c443214cc2a128e95f65cfcc8c54f31587b1a10b Mon Sep 17 00:00:00 2001 From: Gunnar Gabrielson Date: Thu, 12 Mar 2020 11:25:58 -0600 Subject: [PATCH 3/4] suggestions from PR comments --- docs/plugin-syntax-dynamic-import.md | 8 +- .../plugin-syntax-dynamic-import.md | 12 +-- .../plugin-syntax-dynamic-import.md | 8 +- .../plugin-syntax-dynamic-import.md | 8 +- .../plugin-syntax-dynamic-import.md | 99 +++++++++++++++++++ 5 files changed, 114 insertions(+), 21 deletions(-) create mode 100644 website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md diff --git a/docs/plugin-syntax-dynamic-import.md b/docs/plugin-syntax-dynamic-import.md index dc6454428e..4d75b439de 100644 --- a/docs/plugin-syntax-dynamic-import.md +++ b/docs/plugin-syntax-dynamic-import.md @@ -4,14 +4,14 @@ title: @babel/plugin-syntax-dynamic-import sidebar_label: syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. -In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. +This plugin is enabled by default since Babel 7.8.0, so you shouldn't need to enable this plugin separately. -If you want to transpile import(): +**Usage notes:** 1. If you are using `@babel/preset-env`, it's automatically handled -2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you +2. If you are using Webpack or Rollup, you shouldn't transpile `import()` with Babel and let the bundler handle it for you 3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` diff --git a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md index cfc0f7238f..93e8350996 100644 --- a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md @@ -5,15 +5,13 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). +`babel-plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. -In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. +**Usage notes:** -If you want to transpile import(): - -1. If you are using `@babel/preset-env`, it's automatically handled -2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you -3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` +1. If you are using `babel-preset-env`, it's automatically handled +2. If you are using Webpack or Rollup, you shouldn't transpile `import()` with Babel and let the bundler handle it for you +3. Otherwise, you need `babel-plugin-proposal-dynamic-import` ## Installation diff --git a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md index ce9fab3e57..634bb95b4e 100644 --- a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md @@ -5,14 +5,12 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. -In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. - -If you want to transpile import(): +**Usage notes:** 1. If you are using `@babel/preset-env`, it's automatically handled -2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you +2. If you are using Webpack or Rollup, you shouldn't transpile `import()` with Babel and let the bundler handle it for you 3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` ## Installation diff --git a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md index 4dd5291c56..b8d52d3b9a 100644 --- a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md @@ -5,14 +5,12 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for import(). +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. -In Babel 7.8.0 it's enabled by default, so this plugin shouldn't be needed if you are using `@babel/core@>7.8.0`. - -If you want to transpile import(): +**Usage notes:** 1. If you are using `@babel/preset-env`, it's automatically handled -2. If you are using Webpack or Rollup, you shouldn't transpile import() with Babel and let the bundler handle it for you +2. If you are using Webpack or Rollup, you shouldn't transpile `import()` with Babel and let the bundler handle it for you 3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` ## Installation diff --git a/website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md new file mode 100644 index 0000000000..39f21f73e5 --- /dev/null +++ b/website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md @@ -0,0 +1,99 @@ +--- +id: version-7.8.0-babel-plugin-syntax-dynamic-import +title: @babel/plugin-syntax-dynamic-import +sidebar_label: syntax-dynamic-import +original_id: babel-plugin-syntax-dynamic-import +--- + +`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. + +This plugin is enabled by default since Babel 7.8.0, so you shouldn't need to enable this plugin separately. + +**Usage notes:** + +1. If you are using `@babel/preset-env`, it's automatically handled +2. If you are using Webpack or Rollup, you shouldn't transpile `import()` with Babel and let the bundler handle it for you +3. Otherwise, you need `@babel/plugin-proposal-dynamic-import` + + +## Installation + +```sh +npm install --save-dev @babel/plugin-syntax-dynamic-import +``` + +## Usage + +### With a configuration file (Recommended) + +```json +{ + "plugins": ["@babel/plugin-syntax-dynamic-import"] +} +``` + +### Via CLI + +```sh +babel --plugins @babel/plugin-syntax-dynamic-import script.js +``` + +### Via Node API + +```javascript +require("@babel/core").transform("code", { + plugins: ["@babel/plugin-syntax-dynamic-import"], +}); +``` + +## Working with Webpack and @babel/preset-env + +Currently, `@babel/preset-env` is unaware that using `import()` with [Webpack relies on `Promise` internally](https://webpack.js.org/guides/code-splitting/#dynamic-imports). Environments which do not have builtin support for `Promise`, like Internet Explorer, will require both the `promise` and `iterator` polyfills be added manually. + +For example, with `core-js@3`: + +```js +// webpack config +const config = { + entry: [ + "core-js/modules/es.promise", + "core-js/modules/es.array.iterator", + path.resolve(__dirname, "src/main.js"), + ], + // ... +}; +``` + +or + +```js +// src/main.js +import "core-js/modules/es.promise"; +import "core-js/modules/es.array.iterator"; + +// ... +``` + +This is the same for `core-js@2`, except the imports paths are slightly different: + +```js +// webpack config +const config = { + entry: [ + "core-js/modules/es6.promise", + "core-js/modules/es6.array.iterator", + path.resolve(__dirname, "src/main.js"), + ], + // ... +}; +``` + +or + +```js +// src/main.js +import "core-js/modules/es6.promise"; +import "core-js/modules/es6.array.iterator"; + +// ... +``` From ae63fbabb02c119d2128bafa5dac1e29fee2dbe3 Mon Sep 17 00:00:00 2001 From: Gunnar Gabrielson Date: Thu, 12 Mar 2020 11:27:39 -0600 Subject: [PATCH 4/4] suggestions from PR comments - missed one --- docs/plugin-syntax-dynamic-import.md | 2 +- .../version-6.26.3/plugin-syntax-dynamic-import.md | 2 +- .../version-7.0.0/plugin-syntax-dynamic-import.md | 2 +- .../version-7.4.0/plugin-syntax-dynamic-import.md | 2 +- .../version-7.8.0/plugin-syntax-dynamic-import.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/plugin-syntax-dynamic-import.md b/docs/plugin-syntax-dynamic-import.md index 4d75b439de..c10b00d98b 100644 --- a/docs/plugin-syntax-dynamic-import.md +++ b/docs/plugin-syntax-dynamic-import.md @@ -4,7 +4,7 @@ title: @babel/plugin-syntax-dynamic-import sidebar_label: syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. +`@babel/plugin-syntax-dynamic-import` is needed to enable support for parsing `import()` This plugin is enabled by default since Babel 7.8.0, so you shouldn't need to enable this plugin separately. diff --git a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md index 93e8350996..d77247ee83 100644 --- a/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-6.26.3/plugin-syntax-dynamic-import.md @@ -5,7 +5,7 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`babel-plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. +`babel-plugin-syntax-dynamic-import` is needed to enable support for parsing `import()` **Usage notes:** diff --git a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md index 634bb95b4e..cc295b0259 100644 --- a/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.0.0/plugin-syntax-dynamic-import.md @@ -5,7 +5,7 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. +`@babel/plugin-syntax-dynamic-import` is needed to enable support for parsing `import()` **Usage notes:** diff --git a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md index b8d52d3b9a..1f6ac94e24 100644 --- a/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.4.0/plugin-syntax-dynamic-import.md @@ -5,7 +5,7 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. +`@babel/plugin-syntax-dynamic-import` is needed to enable support for parsing `import()` **Usage notes:** diff --git a/website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md b/website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md index 39f21f73e5..985ddc3665 100644 --- a/website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md +++ b/website/versioned_docs/version-7.8.0/plugin-syntax-dynamic-import.md @@ -5,7 +5,7 @@ sidebar_label: syntax-dynamic-import original_id: babel-plugin-syntax-dynamic-import --- -`@babel/plugin-syntax-dynamic-import` is needed to enable parsing for `import()`. +`@babel/plugin-syntax-dynamic-import` is needed to enable support for parsing `import()` This plugin is enabled by default since Babel 7.8.0, so you shouldn't need to enable this plugin separately.