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

Feature request: support the plugin option for swc compiler #35156

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/next/build/swc/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function getBaseSWCOptions({
nextConfig,
resolvedBaseUrl,
jsConfig,
plugin,
}) {
const parserConfig = getParserOptions({ filename, jsConfig })
const paths = jsConfig?.compilerOptions?.paths
Expand Down Expand Up @@ -101,6 +102,7 @@ function getBaseSWCOptions({
removeConsole: nextConfig?.compiler?.removeConsole,
reactRemoveProperties: nextConfig?.compiler?.reactRemoveProperties,
relay: nextConfig?.compiler?.relay,
plugin,
}
}

Expand All @@ -110,6 +112,7 @@ export function getJestSWCOptions({
esm,
nextConfig,
jsConfig,
plugin,
// This is not passed yet as "paths" resolving needs a test first
// resolvedBaseUrl,
}) {
Expand All @@ -121,6 +124,7 @@ export function getJestSWCOptions({
globalWindow: !isServer,
nextConfig,
jsConfig,
plugin,
// resolvedBaseUrl,
})

Expand Down Expand Up @@ -158,6 +162,7 @@ export function getLoaderSWCOptions({
hasReactRefresh,
nextConfig,
jsConfig,
plugin,
// This is not passed yet as "paths" resolving is handled by webpack currently.
// resolvedBaseUrl,
}) {
Expand All @@ -168,6 +173,7 @@ export function getLoaderSWCOptions({
hasReactRefresh,
nextConfig,
jsConfig,
plugin,
// resolvedBaseUrl,
})

Expand Down
3 changes: 2 additions & 1 deletion packages/next/build/webpack/loaders/next-swc-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {

let loaderOptions = this.getOptions() || {}

const { isServer, pagesDir, hasReactRefresh, nextConfig, jsConfig } =
const { isServer, pagesDir, hasReactRefresh, nextConfig, jsConfig, plugin } =
loaderOptions
const isPageFile = filename.startsWith(pagesDir)

Expand All @@ -49,6 +49,7 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
hasReactRefresh,
nextConfig,
jsConfig,
plugin,
})

const programmaticOptions = {
Expand Down