-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add devDependency and loader util for additional bundler
This adds `@rspack/core` as a `devDependency` to Next.js, as it will be conditionally referenced in core in the future and will only run when the real dependency is added via a future plugin. This also creates a `getRspackCore` utility which performs this check, suppresses the lint, and more clearly informs the user of the error.
- Loading branch information
1 parent
cf73ab1
commit b8db5b9
Showing
3 changed files
with
189 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -102,6 +102,7 @@ | |
"@next/third-parties": "workspace:*", | ||
"@opentelemetry/api": "1.4.1", | ||
"@picocss/pico": "1.5.10", | ||
"@rspack/core": "npm:@rspack-canary/[email protected]", | ||
"@svgr/webpack": "5.5.0", | ||
"@swc/cli": "0.1.55", | ||
"@swc/core": "1.9.3", | ||
|
This file contains 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,16 @@ | ||
import type * as RspackCore from '@rspack/core' | ||
|
||
export function getRspackCore(): typeof RspackCore { | ||
try { | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
return require('@rspack/core') | ||
} catch (e) { | ||
if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') { | ||
throw new Error( | ||
'@rspack/core is not available. Please make sure the appropriate Next.js plugin is installed.' | ||
) | ||
} | ||
|
||
throw e | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.