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

chore(components): do not bundle styled components in dist #16798

Open
wants to merge 1 commit into
base: edge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"homepage": "https://github.com/Opentrons/opentrons#readme",
"peerDependencies": {
"react": "18.2.0",
"react-dom": "18.2.0"
"react-dom": "18.2.0",
"styled-components": "5.3.6"
},
"dependencies": {
"@opentrons/shared-data": "link:../shared-data",
Expand Down
14 changes: 10 additions & 4 deletions components/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import lostCss from 'lost'
export default defineConfig({
build: {
// Relative to the root
ssr: 'src/index.ts',
outDir: 'lib',
// do not delete the outdir, typescript types might live there and we dont want to delete them
emptyOutDir: false,
commonjsOptions: {
transformMixedEsModules: true,
esmExternals: true,
lib: {
entry: 'src/index.ts',
formats: ['es', 'cjs'], // Generate both ES Module and CommonJS outputs
fileName: (format) => (format === 'es' ? 'index.mjs' : 'index.cjs'),
},
rollupOptions: {
external: ['react', 'react-dom', 'styled-components'], // Ensure peer dependencies are not bundled
},
target: 'es2017', // Transpile down to a compatible version for Next.js (for Protocol Library)
},
plugins: [
react({
Expand All @@ -32,6 +36,7 @@ export default defineConfig({
esbuildOptions: {
target: 'es2020',
},
exclude: ['styled-components'], // Avoid pre-bundling styled-components
},
css: {
postcss: {
Expand All @@ -55,5 +60,6 @@ export default defineConfig({
'../components/src/index.module.css'
),
},
dedupe: ['styled-components'], // Prevent duplicate styled-components instances
},
})
Loading