Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack can't split parts of a single module (e.g. rollup bundle from a dependency) into separate chunks? #7780

Closed
jedwards1211 opened this issue Jul 24, 2018 · 1 comment

Comments

@jedwards1211
Copy link

jedwards1211 commented Jul 24, 2018

Bug report

What is the current behavior?

Forgive me if I've misconfigured something, but it seems like if I import {Toggle} from 'react-powerplug' in chunk A and import {Interval} from 'react-powerplug' in chunk B, all of the react-powerplug code winds up in chunk A, because react-powerplug exports a single rollup bundled js module.

If the current behavior is a bug, please provide the steps to reproduce.

https://github.com/jedwards1211/webpack-code-splitting-issue
just clone, yarn install and run webpack. The output dist/main.js will contain all of the code being used from react-powerplug; the dist/1.js chunk imports Interval from main.js.

Here is what the relevant code looks like:

src/index.js

import {Toggle} from 'react-powerplug'
console.log(Toggle)

import('./chunk-b')

The output dist/main.js on my machine contained all of the code I used from react-powerplug, whereas dist/1.js just imports Interval from main.js:

(window.webpackJsonp=window.webpackJsonp||[]).push([[1],{3:function(o,n,s){"use strict";s.r(n);var w=s(1);console.log(w.a)}}]);

src/chunk-b.js

import {Interval} from 'react-powerplug'
console.log(Interval)

What is the expected behavior?

Code for react-powerplug's Toggle winds up in main.js, and code for Interval winds up in 1.js.

Given that it's becoming popular to release packages as rollup bundles, I want to make sure webpack will be able to include part of that rollup bundle in one chunk, and another part of the bundle in another.

Other relevant information:
webpack version: 4.16.2
Node.js version: 8
Operating System: macOS

@jedwards1211
Copy link
Author

I'm going to close this as basically a duplicate of #7782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant