Skip to content
Merged
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: 3 additions & 0 deletions crates/next-core/src/segment_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ pub async fn parse_segment_config_from_source(
EcmascriptModuleAssetType::Ecmascript
},
EcmascriptInputTransforms::empty(),
// node_env is not used here: EcmascriptInputTransforms::empty() means no
// transforms are applied, so TransformContext::node_env is never accessed.
rcstr!("development"),
false,
false,
)
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/swc-plugins-env/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Root({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
6 changes: 6 additions & 0 deletions test/e2e/swc-plugins-env/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ENV_CHECK will be replaced by the SWC plugin with "development" or "production"
declare const ENV_CHECK: string

export default function Home() {
return <main>The SWC plugin received env={ENV_CHECK}</main>
}
18 changes: 18 additions & 0 deletions test/e2e/swc-plugins-env/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { nextTestSetup } from 'e2e-utils'

describe('swc-plugins-env', () => {
const { next, skipped, isNextDev } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) return

it('should pass correct environment to swc plugins', async () => {
const $ = await next.render$('/')
if (isNextDev) {
expect($('main').text()).toBe('The SWC plugin received env=development')
} else {
expect($('main').text()).toBe('The SWC plugin received env=production')
}
})
})
6 changes: 6 additions & 0 deletions test/e2e/swc-plugins-env/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
swcPlugins: [['./swc_plugin_env_check.wasm', {}]],
},
}
Loading
Loading