Skip to content

Vite fixes (default exports, circular dependency)#24591

Merged
ryanclark merged 4 commits intomasterfrom
ryan/vite-fix-default-cjs
Apr 14, 2023
Merged

Vite fixes (default exports, circular dependency)#24591
ryanclark merged 4 commits intomasterfrom
ryan/vite-fix-default-cjs

Conversation

@ryanclark
Copy link
Copy Markdown
Member

@ryanclark ryanclark commented Apr 14, 2023

This fixes an issue with Vite production builds where certain libraries that export things a bit differently don't work (vitejs/vite#2139).

To do this, we're using the ESModule interop (checking for .default) instead of the Vite config change as it doesn't work with node v16

Also this removes a circular dependency that Vite has been detecting in production builds

Export "SelectResource" of module "../../../web/packages/teleport/src/Discover/SelectResource/SelectResource.tsx" was reexported through module "../../../web/packages/teleport/src/Discover/SelectResource/index.ts" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "../../../web/packages/teleport/src/Discover/Discover.tsx" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.

Comment thread web/packages/build/vite/config.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as RollupCommonJSOptions is not needed, commonjsOptions is already typed properly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed

@ryanclark ryanclark enabled auto-merge April 14, 2023 09:55
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from ibeckermayer April 14, 2023 09:55
@ryanclark ryanclark added this pull request to the merge queue Apr 14, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 14, 2023
@ryanclark ryanclark added this pull request to the merge queue Apr 14, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 14, 2023
@ryanclark ryanclark force-pushed the ryan/vite-fix-default-cjs branch from f9959e6 to 2e70050 Compare April 14, 2023 10:54
@ryanclark ryanclark force-pushed the ryan/vite-fix-default-cjs branch from 2e70050 to 1133d7c Compare April 14, 2023 11:04
@ryanclark ryanclark enabled auto-merge April 14, 2023 11:04
@ryanclark ryanclark added this pull request to the merge queue Apr 14, 2023
Merged via the queue into master with commit ce939be Apr 14, 2023
@ryanclark ryanclark deleted the ryan/vite-fix-default-cjs branch April 14, 2023 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants