Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
06f3d398
Unverified
Commit
06f3d398
authored
Nov 12, 2021
by
JJ Kasper
Committed by
GitHub
Nov 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure NODE_ENV is replaced correctly with swc (#31274)
parent
f796ea3e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
options.js
packages/next/build/swc/options.js
+4
-0
index.test.js
...egration/non-standard-node-env-warning/test/index.test.js
+26
-1
next-test-utils.js
test/lib/next-test-utils.js
+1
-1
No files found.
packages/next/build/swc/options.js
View file @
06f3d398
...
@@ -44,6 +44,10 @@ function getBaseSWCOptions({
...
@@ -44,6 +44,10 @@ function getBaseSWCOptions({
typeofs
:
{
typeofs
:
{
window
:
globalWindow
?
'object'
:
'undefined'
,
window
:
globalWindow
?
'object'
:
'undefined'
,
},
},
envs
:
{
NODE_ENV
:
development
?
'"development"'
:
'"production"'
,
},
// TODO: handle process.browser to match babel replacing as well
},
},
},
},
regenerator
:
{
regenerator
:
{
...
...
test/integration/non-standard-node-env-warning/test/index.test.js
View file @
06f3d398
/* eslint-env jest */
/* eslint-env jest */
import
glob
from
'glob'
import
fs
from
'fs-extra'
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
{
import
{
findPort
,
findPort
,
...
@@ -7,6 +8,7 @@ import {
...
@@ -7,6 +8,7 @@ import {
killApp
,
killApp
,
waitFor
,
waitFor
,
initNextServerScript
,
initNextServerScript
,
nextBuild
,
}
from
'next-test-utils'
}
from
'next-test-utils'
const
appDir
=
join
(
__dirname
,
'..'
)
const
appDir
=
join
(
__dirname
,
'..'
)
...
@@ -77,6 +79,29 @@ describe('Non-Standard NODE_ENV', () => {
...
@@ -77,6 +79,29 @@ describe('Non-Standard NODE_ENV', () => {
expect
(
output
).
not
.
toContain
(
warningText
)
expect
(
output
).
not
.
toContain
(
warningText
)
})
})
it
(
'should still DCE NODE_ENV specific code'
,
async
()
=>
{
await
nextBuild
(
appDir
,
undefined
,
{
env
:
{
NODE_ENV
:
'test'
,
},
})
const
staticFiles
=
glob
.
sync
(
'**/*.js'
,
{
cwd
:
join
(
appDir
,
'.next/static'
),
})
expect
(
staticFiles
.
length
).
toBeGreaterThan
(
0
)
for
(
const
file
of
staticFiles
)
{
const
content
=
await
fs
.
readFile
(
join
(
appDir
,
'.next/static'
,
file
),
'utf8'
)
if
(
content
.
match
(
/cannot find module/i
))
{
throw
new
Error
(
`
${
file
}
contains module not found error`
)
}
}
})
it
(
'should show the warning with NODE_ENV set to invalid value'
,
async
()
=>
{
it
(
'should show the warning with NODE_ENV set to invalid value'
,
async
()
=>
{
let
output
=
''
let
output
=
''
...
...
test/lib/next-test-utils.js
View file @
06f3d398
...
@@ -129,10 +129,10 @@ export function runNextCommand(argv, options = {}) {
...
@@ -129,10 +129,10 @@ export function runNextCommand(argv, options = {}) {
// Let Next.js decide the environment
// Let Next.js decide the environment
const
env
=
{
const
env
=
{
...
process
.
env
,
...
process
.
env
,
...
options
.
env
,
NODE_ENV
:
''
,
NODE_ENV
:
''
,
__NEXT_TEST_MODE
:
'true'
,
__NEXT_TEST_MODE
:
'true'
,
NEXT_PRIVATE_OUTPUT_TRACE_ROOT
:
path
.
join
(
__dirname
,
'../../'
),
NEXT_PRIVATE_OUTPUT_TRACE_ROOT
:
path
.
join
(
__dirname
,
'../../'
),
...
options
.
env
,
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment