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

fix(runtime): add lazy load for addtl bundlers #3364

Conversation

rwaskiewicz
Copy link
Contributor

Important

This is going to be the final part part of a chain of PRs*. Once all of them are up/approved, I'll merge the child-most PR into its parent, that parent into its own parent, etc. At the end, we shall have a PR (#3349) which contains all of its children, and we'll commit it as one large commit.

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features) - docs(extras): add documentation for experimentalImportInjection site#876
  • Build (npm run build) was run locally and any changes were pushed
  • Unit tests (npm test) were run locally and passed
  • E2E Tests (npm run test.karma.prod) were run locally and passed
  • Prettier (npm run prettier) was run locally and passed

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature (this change could really be considered as either)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Supersedes: #2959

What is the new behavior?

this commit adds experimental support for using stencil component
libraries in projects that use bundlers such as vite. prior to this
commit, stencil component libraries that were used in projects that used
such bundlers would have issues lazily-loading components at runtime.
this is due to restrictions the bundlers themselves place on the
filepaths that can be used in dynamic import statements.

this commit does not introduce the ability for stencil's compiler to use
bundlers other than rollup under the hood. it only permits a compiled
component library (that uses the dist output target) to be used in an
application that uses a bundler built atop of rollup.

due to the restrictions that rollup may impose on dynamic imports, this
commit adds the ability to add an explicit import() statement for each
lazily-loadable bundle. in order to keep the runtime small, this feature
is hidden behind a new feature flag, experimentalImportInjection

this pr build's atop the work done by @johnjenkins in
#2959 and the test cases
provided by @PrinceManfred in
#2959 (comment).
Without their contributions, this commit would not have been possible.

STENCIL-339: Integrate Bundler Functionality

Does this introduce a breaking change?

  • Yes
  • No

Testing

Other Information

Since this is a part of a chain, please do not use GH to 'Update Branch' - I'll take care of that manually (and be careful not to rebase mid-review cycle).

Upon merging the entire chain, I'll update GH to require the bundler tests to merge (so they won't show up in the list of passed checks in the PR summary down below)

Footnotes

* I am going to be assuming tech debt for getting Parcel-based tests into this chain, and am going to defer to those at a later time

this commit adds experimental support for using stencil component
libraries in projects that use bundlers such as vite. prior to this
commit, stencil component libraries that were used in projects that used
such bundlers would have issues lazily-loading components at runtime.
this is due to restrictions the bundlers themselves place on the
filepaths that can be used in dynamic import statements.

this commit does not introduce the ability for stencil's compiler to use
bundlers other than rollup under the hood. it only permits a compiled
component library (that uses the `dist` output target) to be used in an
application that uses a bundler built atop of rollup.

due to the restrictions that rollup may impose on dynamic imports, this
commit adds the ability to add an explicit `import()` statement for each
lazily-loadable bundle. in order to keep the runtime small, this feature
is hidden behind a new feature flag, `experimentalImportInjection`

this pr build's atop the work done by @johnjenkins in
#2959 and the test cases
provided by @PrinceManfred in
#2959 (comment).
Without their contributions, this commit would not have been possible.

STENCIL-339: Integrate Bundler Functionality
Copy link
Contributor

@alicewriteswrongs alicewriteswrongs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing I noticed

isBrowserBuild
);
})
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like moving down the Promise.all here leaves us with two nested Promise.all calls (lines 33 and 34), I think we could consolidate that down to just one while we're in here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixed in cd3f228

Copy link
Contributor

@alicewriteswrongs alicewriteswrongs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested out the code locally and it looks like everything is working and whatnot! we might want to just address that Promise.all([Promise.all(...)]) thing

remove two nested `Promise.all` calls - after moving writing lazily
loadable chunks out of the outermost `Promise.all` call, we were
awaiting a single promise wrapped in an array. this commit simplifies
the code
@rwaskiewicz rwaskiewicz merged commit 25cef1e into rwaskiewicz/bundlers/vite-and-karma May 10, 2022
@rwaskiewicz rwaskiewicz deleted the rwaskiewicz/impl-import-injection branch May 10, 2022 18:36
rwaskiewicz added a commit that referenced this pull request May 10, 2022
* fix(runtime): add lazy load for addtl bundlers

this commit adds experimental support for using stencil component
libraries in projects that use bundlers such as vite. prior to this
commit, stencil component libraries that were used in projects that used
such bundlers would have issues lazily-loading components at runtime.
this is due to restrictions the bundlers themselves place on the
filepaths that can be used in dynamic import statements.

this commit does not introduce the ability for stencil's compiler to use
bundlers other than rollup under the hood. it only permits a compiled
component library (that uses the `dist` output target) to be used in an
application that uses a bundler built atop of rollup.

due to the restrictions that rollup may impose on dynamic imports, this
commit adds the ability to add an explicit `import()` statement for each
lazily-loadable bundle. in order to keep the runtime small, this feature
is hidden behind a new feature flag, `experimentalImportInjection`

this pr build's atop the work done by @johnjenkins in
#2959 and the test cases
provided by @PrinceManfred in
#2959 (comment).
Without their contributions, this commit would not have been possible.

STENCIL-339: Integrate Bundler Functionality

* review(ap): remove unnecessary nested `Promise.all` calls

remove two nested `Promise.all` calls - after moving writing lazily
loadable chunks out of the outermost `Promise.all` call, we were
awaiting a single promise wrapped in an array. this commit simplifies
the code
rwaskiewicz added a commit that referenced this pull request May 10, 2022
* fix(runtime): add lazy load for addtl bundlers

this commit adds experimental support for using stencil component
libraries in projects that use bundlers such as vite. prior to this
commit, stencil component libraries that were used in projects that used
such bundlers would have issues lazily-loading components at runtime.
this is due to restrictions the bundlers themselves place on the
filepaths that can be used in dynamic import statements.

this commit does not introduce the ability for stencil's compiler to use
bundlers other than rollup under the hood. it only permits a compiled
component library (that uses the `dist` output target) to be used in an
application that uses a bundler built atop of rollup.

due to the restrictions that rollup may impose on dynamic imports, this
commit adds the ability to add an explicit `import()` statement for each
lazily-loadable bundle. in order to keep the runtime small, this feature
is hidden behind a new feature flag, `experimentalImportInjection`

this pr build's atop the work done by @johnjenkins in
#2959 and the test cases
provided by @PrinceManfred in
#2959 (comment).
Without their contributions, this commit would not have been possible.

STENCIL-339: Integrate Bundler Functionality

* review(ap): remove unnecessary nested `Promise.all` calls

remove two nested `Promise.all` calls - after moving writing lazily
loadable chunks out of the outermost `Promise.all` call, we were
awaiting a single promise wrapped in an array. this commit simplifies
the code
rwaskiewicz added a commit that referenced this pull request May 13, 2022
* fix(runtime): add lazy load for addtl bundlers

this commit adds experimental support for using stencil component
libraries in projects that use bundlers such as vite. prior to this
commit, stencil component libraries that were used in projects that used
such bundlers would have issues lazily-loading components at runtime.
this is due to restrictions the bundlers themselves place on the
filepaths that can be used in dynamic import statements.

this commit does not introduce the ability for stencil's compiler to use
bundlers other than rollup under the hood. it only permits a compiled
component library (that uses the `dist` output target) to be used in an
application that uses a bundler built atop of rollup.

due to the restrictions that rollup may impose on dynamic imports, this
commit adds the ability to add an explicit `import()` statement for each
lazily-loadable bundle. in order to keep the runtime small, this feature
is hidden behind a new feature flag, `experimentalImportInjection`

this pr build's atop the work done by @johnjenkins in
#2959 and the test cases
provided by @PrinceManfred in
#2959 (comment).
Without their contributions, this commit would not have been possible.

STENCIL-339: Integrate Bundler Functionality

* review(ap): remove unnecessary nested `Promise.all` calls

remove two nested `Promise.all` calls - after moving writing lazily
loadable chunks out of the outermost `Promise.all` call, we were
awaiting a single promise wrapped in an array. this commit simplifies
the code
@lkononenko
Copy link

Thanks for an amazing work! Do you have any estimation when it can be released?

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

Successfully merging this pull request may close these issues.

3 participants