Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

[bundler] Multiple import() statements for the same fragment breaks bundles #568

Closed keanulee closed 5 years ago

keanulee commented 6 years ago

When I edit:

https://github.com/Polymer/pwa-starter-kit/blob/b50a93748677c8be0bdcdc5ed71a03747628fc57/src/actions/app.js#L31-L39

  switch(page) {
    case 'view1':
      import('../components/my-view1.js').then((module) => {
        // Put code in here that you want to run every time when
        // navigating to view1 after my-view1.js is loaded.
      });
      break;
    case 'view2':
      import('../components/my-view2.js');
      break;

To:

    case 'view1':
      import('../components/my-view1.js').then((module) => {
        // Put code in here that you want to run every time when
        // navigating to view1 after my-view1.js is loaded.
      });

      import('../components/my-view2.js');

      break;
    case 'view2':
      import('../components/my-view2.js');
      break;

The resulting shell bundle (my-app.js) doesn't export some identifiers used by the fragments like LitElement and html.

Ref https://github.com/Polymer/pwa-starter-kit/issues/190

abdonrd commented 6 years ago

@usergenic any news about this? 🙂

LarsDenBakker commented 5 years ago

This is a serious bug, not very encouraging that it's been open since july :(

RobMaskell commented 5 years ago

Strangely hit this two days ago and it took a while to unwind it

usergenic commented 5 years ago

FWIW, working on this via Polymer/tools#722 - rollup has some unfortunate assumptions and its own new logic around deduplicating dynamic imports that I'm attempting to get around. Solution soon.

usergenic commented 5 years ago

Filed a bug on rollup https://github.com/rollup/rollup/issues/2487

usergenic commented 5 years ago

Filed a bug on rollup https://github.com/rollup/rollup/issues/2487

usergenic commented 5 years ago

Filed another bug on rollup https://github.com/rollup/rollup/issues/2489

usergenic commented 5 years ago

Fixed by https://github.com/Polymer/tools/pull/722