Babel plugin that transforms dynamic import() calls into universal imports with chunk name magic comments, designed for use with react-universal-component and extract-css-chunks-webpack-plugin. Current stable version is 3.1.3 (v4.x exists but with breaking changes). Release cadence is sporadic; last v3 release was 2018-10-01, last v4 release 2020-04-15. Key differentiator: automatically generates chunk names, resolve paths, and CSS chunk loading boilerplate. Requires webpack 4+ and Babel 7+. Alternative to manual webpack magic comment management.
npm install babel-plugin-universal-importVerified import paths — ran on the pinned version, not inferred.
Setup Babel plugin and use with react-universal-component for automatic code splitting with chunk naming.
Update any hardcoded chunk references to use hyphens instead of slashes.
If upgrading from v3, remove any custom chunk renaming logic; let webpack handle names via magic comments.
Pin to 3.1.3 if stable; evaluate v4 breaking changes before upgrading.
Upgrade to 3.0.2+ which uses constant string paths for helper to avoid warnings.
Ensure dynamic imports use `webpackChunkName: '[request]'` inside import() comments.
Upgrade to Babel 7 or use v2.x (which supports Babel 6 but with fewer features).
Use ESM import: `import universalImport from 'babel-plugin-universal-import/universalImport.js'`
Run `npm install babel-plugin-universal-import` and add 'universal-import' to plugins array.
Upgrade to v3+ which includes the helper. Import from 'babel-plugin-universal-import/universalImport.js'.