babel-plugin-universal-import
Advanced tools
Comparing version 1.1.10 to 1.1.11
{ | ||
"name": "babel-plugin-universal-import", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "Babel plugin to transform import() into its Universal counterpart", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,2 +51,3 @@ # babel-plugin-universal-import [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square)](https://gitter.im/faceyspacey/Lobby) | ||
```js | ||
import universal from 'react-universal-component' | ||
universal(import('./Foo.js')) | ||
@@ -56,2 +57,3 @@ | ||
import universal from 'react-universal-component' | ||
import universalImport from 'babel-plugin-universal-import/universalImport.js' | ||
@@ -74,2 +76,3 @@ import importCss from 'babel-plugin-universal-import/importCss.js' | ||
```js | ||
import universal from 'react-universal-component' | ||
universal(({ page }) => import(`../async/${page}`)) | ||
@@ -79,2 +82,3 @@ | ||
import universal from 'react-universal-component' | ||
import universalImport from 'babel-plugin-universal-import/universalImport.js' | ||
@@ -93,2 +97,3 @@ import importCss from 'babel-plugin-universal-import/importCss.js' | ||
``` | ||
> NOTE: if you aren't using `react-universal-component` and you just want to serve CSS chunks from [extract-css-chunks-webpack-plugin](https://www.npmjs.com/package/extract-css-chunks-webpack-plugin), use [babel-plugin-dual-import]([babel-plugin-universal-import](https://github.com/faceyspacey/babel-plugin-universal-import) instead. | ||
@@ -101,3 +106,3 @@ It names all your chunks using *magic comments* 🔮 behind the scenes and is derived from the imported file. This works with both static and dynamic import paths, as you can see above. | ||
Perhaps the coolest part however is that it also attempts to import a separate CSS file along with js chunks for optimum chunk sizes, caching and performance. Look in what `Promise.all` does. | ||
Perhaps the coolest part however is that it also attempts to import a separate CSS file along with js chunks for optimum chunk sizes, caching and performance. Look in what `Promise.all` does. To fulfill this mission you must be using [extract-css-chunks-webpack-plugin](https://www.npmjs.com/package/extract-css-chunks-webpack-plugin) to create multiple CSS chunks for dynamic imports. | ||
@@ -104,0 +109,0 @@ And maybe even *cooler* to some: you don't have to do `universal(() => import())`. I.e. you don't have to wrap it in a function any longer when using `react-universal-component`, similar to `dynamic(import())` in Next.js...*unless of course you're making use of the awesome props feature, as showcased via the `page` prop.* |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
351668
128