-
Notifications
You must be signed in to change notification settings - Fork 673
refactor(project): update project to use rolldown over rollup #7263
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
806c27f
refactor(import-css): update plugin to work with rolldown
joshblack ccb3896
refactor(project): update project to use rolldown over rollup
joshblack 5a45a03
chore: remove build step from rolldown-plugin-import-css
joshblack fff4add
fix: change async handler to sync
joshblack 4ce21b0
fix: add external dependencies
joshblack 7eab515
refactor: remove preserve-directives plugin
joshblack b1f2d0a
chore: fix lint errors
joshblack 332f35f
fix: restore dependencies for get-export-sizes.cjs
joshblack c9115b5
Apply suggestions from code review
joshblack 5a090b6
Update packages/react/rolldown.config.mjs
joshblack 39ddc63
Merge branch 'main' into refactor/update-project-from-rollup-to-rolldown
joshblack dbe1fbf
Merge branch 'main' into refactor/update-project-from-rollup-to-rolldown
joshblack a548637
Merge branch 'main' into refactor/update-project-from-rollup-to-rolldown
joshblack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,5 +4,6 @@ | |
| "emitDeclarationOnly": true, | ||
| "outDir": "./dist", | ||
| "rootDir": "./src" | ||
| } | ||
| }, | ||
| "exclude": ["**/__tests__/**"] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import babel from '@rollup/plugin-babel' | ||
| import {importCSS} from 'rolldown-plugin-import-css' | ||
| import postcssPresetPrimer from 'postcss-preset-primer' | ||
| import MagicString from 'magic-string' | ||
| import {defineConfig} from 'rolldown' | ||
| import {isSupported} from './script/react-compiler.mjs' | ||
| import packageJson from './package.json' with {type: 'json'} | ||
|
|
||
| const extensions = ['.js', '.jsx', '.ts', '.tsx'] | ||
| const dependencies = [ | ||
| ...Object.keys(packageJson.peerDependencies ?? {}), | ||
| ...Object.keys(packageJson.dependencies ?? {}), | ||
| ...Object.keys(packageJson.devDependencies ?? {}), | ||
| ] | ||
|
|
||
| function createPackageRegex(name) { | ||
| return new RegExp(`^${name}(/.*)?`) | ||
| } | ||
|
|
||
| const postcssModulesOptions = { | ||
| generateScopedName: 'prc-[folder]-[local]-[hash:base64:5]', | ||
| } | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| input: [ | ||
| // "exports" | ||
| // "." | ||
| 'src/index.ts', | ||
|
|
||
| // "./experimental" | ||
| 'src/experimental/index.ts', | ||
|
|
||
| // "./deprecated" | ||
| 'src/deprecated/index.ts', | ||
|
|
||
| // "./next" | ||
| 'src/next/index.ts', | ||
| ], | ||
| external: dependencies.map(createPackageRegex), | ||
| plugins: [ | ||
| babel({ | ||
| extensions, | ||
| exclude: /node_modules/, | ||
| babelHelpers: 'inline', | ||
| babelrc: false, | ||
| configFile: false, | ||
| presets: [ | ||
| '@babel/preset-typescript', | ||
| [ | ||
| '@babel/preset-react', | ||
| { | ||
| modules: false, | ||
| runtime: 'automatic', | ||
| }, | ||
| ], | ||
| ], | ||
| plugins: [ | ||
| [ | ||
| 'babel-plugin-react-compiler', | ||
| { | ||
| target: '18', | ||
| sources: filepath => isSupported(filepath), | ||
| }, | ||
| ], | ||
| 'add-react-displayname', | ||
| 'dev-expression', | ||
| [ | ||
| 'babel-plugin-transform-replace-expressions', | ||
| { | ||
| replace: { | ||
| __DEV__: "process.env.NODE_ENV !== 'production'", | ||
| }, | ||
| }, | ||
| ], | ||
| ], | ||
| }), | ||
| importCSS({ | ||
| modulesRoot: 'src', | ||
| postcssPlugins: [postcssPresetPrimer()], | ||
| postcssModulesOptions, | ||
| }), | ||
| ], | ||
| onwarn(warning, defaultHandler) { | ||
| // Dependencies or modules may use "use client" as an indicator for React | ||
| // Server Components that this module should only be loaded on the client. | ||
| if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && warning.message.includes('use client')) { | ||
| return | ||
| } | ||
|
|
||
| if (warning.code === 'CIRCULAR_DEPENDENCY') { | ||
| throw warning | ||
| } | ||
|
|
||
| defaultHandler(warning) | ||
| }, | ||
| output: { | ||
| dir: 'dist', | ||
| format: 'esm', | ||
| preserveModules: true, | ||
| preserveModulesRoot: 'src', | ||
| }, | ||
| }, | ||
| { | ||
| input: { | ||
| 'test-helpers': 'src/utils/test-helpers.tsx', | ||
| }, | ||
| platform: 'node', | ||
| output: { | ||
| dir: 'dist', | ||
| format: 'esm', | ||
| preserveModules: true, | ||
| preserveModulesRoot: 'src', | ||
| }, | ||
| }, | ||
| ]) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.