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
3b382a08
Unverified
Commit
3b382a08
authored
May 18, 2020
by
Jan Potoms
Committed by
GitHub
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve jsconfig.json error message (#13053)
parent
f5c8b428
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
1 deletion
+55
-1
webpack-config.ts
packages/next/build/webpack-config.ts
+11
-1
package.json
packages/next/package.json
+2
-0
jsconfig.json
test/integration/jsconfig/jsconfig.json
+1
-0
hello.js
test/integration/jsconfig/pages/hello.js
+1
-0
index.test.js
test/integration/jsconfig/test/index.test.js
+35
-0
yarn.lock
yarn.lock
+5
-0
No files found.
packages/next/build/webpack-config.ts
View file @
3b382a08
...
@@ -51,6 +51,7 @@ import WebpackConformancePlugin, {
...
@@ -51,6 +51,7 @@ import WebpackConformancePlugin, {
ReactSyncScriptsConformanceCheck
,
ReactSyncScriptsConformanceCheck
,
}
from
'./webpack/plugins/webpack-conformance-plugin'
}
from
'./webpack/plugins/webpack-conformance-plugin'
import
{
WellKnownErrorsPlugin
}
from
'./webpack/plugins/wellknown-errors-plugin'
import
{
WellKnownErrorsPlugin
}
from
'./webpack/plugins/wellknown-errors-plugin'
import
{
codeFrameColumns
}
from
'@babel/code-frame'
type
ExcludesFalse
=
<
T
>
(
x
:
T
|
false
)
=>
x
is
T
type
ExcludesFalse
=
<
T
>
(
x
:
T
|
false
)
=>
x
is
T
...
@@ -65,7 +66,16 @@ const escapePathVariables = (value: any) => {
...
@@ -65,7 +66,16 @@ const escapePathVariables = (value: any) => {
function
parseJsonFile
(
path
:
string
)
{
function
parseJsonFile
(
path
:
string
)
{
const
JSON5
=
require
(
'next/dist/compiled/json5'
)
const
JSON5
=
require
(
'next/dist/compiled/json5'
)
const
contents
=
readFileSync
(
path
)
const
contents
=
readFileSync
(
path
)
return
JSON5
.
parse
(
contents
)
try
{
return
JSON5
.
parse
(
contents
)
}
catch
(
err
)
{
const
codeFrame
=
codeFrameColumns
(
String
(
contents
),
{
start
:
{
line
:
err
.
lineNumber
,
column
:
err
.
columnNumber
}
},
{
message
:
err
.
message
,
highlightCode
:
true
}
)
throw
new
Error
(
`Failed to parse "
${
path
}
":\n
${
codeFrame
}
`
)
}
}
}
function
getOptimizedAliases
(
isServer
:
boolean
):
{
[
pkg
:
string
]:
string
}
{
function
getOptimizedAliases
(
isServer
:
boolean
):
{
[
pkg
:
string
]:
string
}
{
...
...
packages/next/package.json
View file @
3b382a08
...
@@ -59,6 +59,7 @@
...
@@ -59,6 +59,7 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"@ampproject/toolbox-optimizer"
:
"2.3.1"
,
"@ampproject/toolbox-optimizer"
:
"2.3.1"
,
"@babel/code-frame"
:
"7.8.3"
,
"@babel/core"
:
"7.7.7"
,
"@babel/core"
:
"7.7.7"
,
"@babel/plugin-proposal-class-properties"
:
"7.8.3"
,
"@babel/plugin-proposal-class-properties"
:
"7.8.3"
,
"@babel/plugin-proposal-nullish-coalescing-operator"
:
"7.8.3"
,
"@babel/plugin-proposal-nullish-coalescing-operator"
:
"7.8.3"
,
...
@@ -119,6 +120,7 @@
...
@@ -119,6 +120,7 @@
"@taskr/esnext"
:
"1.1.0"
,
"@taskr/esnext"
:
"1.1.0"
,
"@taskr/watch"
:
"1.1.0"
,
"@taskr/watch"
:
"1.1.0"
,
"@types/amphtml-validator"
:
"1.0.0"
,
"@types/amphtml-validator"
:
"1.0.0"
,
"@types/babel__code-frame"
:
"7.0.1"
,
"@types/babel__core"
:
"7.1.7"
,
"@types/babel__core"
:
"7.1.7"
,
"@types/babel__generator"
:
"7.6.1"
,
"@types/babel__generator"
:
"7.6.1"
,
"@types/babel__template"
:
"7.0.2"
,
"@types/babel__template"
:
"7.0.2"
,
...
...
test/integration/jsconfig/jsconfig.json
0 → 100644
View file @
3b382a08
{}
test/integration/jsconfig/pages/hello.js
0 → 100644
View file @
3b382a08
export
default
()
=>
<
div
>
hello
world
<
/div
>
test/integration/jsconfig/test/index.test.js
0 → 100644
View file @
3b382a08
/* eslint-env jest */
import
fs
from
'fs-extra'
import
{
join
}
from
'path'
import
{
nextBuild
}
from
'next-test-utils'
jest
.
setTimeout
(
1000
*
60
*
2
)
const
appDir
=
join
(
__dirname
,
'..'
)
describe
(
'jsconfig.json'
,
()
=>
{
it
(
'should build normally'
,
async
()
=>
{
const
res
=
await
await
nextBuild
(
appDir
,
[],
{
stdout
:
true
})
expect
(
res
.
stdout
).
toMatch
(
/Compiled successfully
\.
/
)
})
it
(
'should fail on invalid jsconfig.json'
,
async
()
=>
{
const
jsconfigPath
=
join
(
appDir
,
'jsconfig.json'
)
const
originalJsconfig
=
await
fs
.
readFile
(
jsconfigPath
,
{
encoding
:
'utf-8'
,
})
await
fs
.
writeFile
(
jsconfigPath
,
'{'
,
{
encoding
:
'utf-8'
,
})
try
{
const
res
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
expect
(
res
.
stderr
).
toMatch
(
/Error: Failed to parse "/
)
expect
(
res
.
stderr
).
toMatch
(
/JSON5: invalid end of input at 1:2/
)
}
finally
{
await
fs
.
writeFile
(
jsconfigPath
,
originalJsconfig
,
{
encoding
:
'utf-8'
,
})
}
})
})
yarn.lock
View file @
3b382a08
...
@@ -2689,6 +2689,11 @@
...
@@ -2689,6 +2689,11 @@
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==
integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==
"@types/babel__code-frame@7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@types/babel__code-frame/-/babel__code-frame-7.0.1.tgz#baf2529c4abbfb5e4008c845efcfe39a187e2f99"
integrity sha512-FFfbQozKxYmOnCKFYV+EQprjBI7u2yaNc2ly/K9AhzyC8MzXtCtSRqptpw+HUJxhwCOo5mLwf1ATmzyhOaVbDg==
"@types/babel__core@7.1.7", "@types/babel__core@^7.1.7":
"@types/babel__core@7.1.7", "@types/babel__core@^7.1.7":
version "7.1.7"
version "7.1.7"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.7.tgz#1dacad8840364a57c98d0dd4855c6dd3752c6b89"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.7.tgz#1dacad8840364a57c98d0dd4855c6dd3752c6b89"
...
...
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