diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 31e1e98b77..d9be1a2ae8 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -60,7 +60,7 @@ const escapePathVariables = (value: any) => { } function parseJsonFile(path: string) { - const JSON5 = require('json5') + const JSON5 = require('next/dist/compiled/json5') const contents = readFileSync(path) return JSON5.parse(contents) } diff --git a/packages/next/lib/find-config.ts b/packages/next/lib/find-config.ts index 5d4089479e..ba92287d69 100644 --- a/packages/next/lib/find-config.ts +++ b/packages/next/lib/find-config.ts @@ -1,6 +1,6 @@ import findUp from 'find-up' import fs from 'fs' -import JSON5 from 'json5' +import JSON5 from 'next/dist/compiled/json5' type RecursivePartial = { [P in keyof T]?: RecursivePartial diff --git a/packages/next/package.json b/packages/next/package.json index 45b064f7c4..ba0182e22c 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -71,7 +71,6 @@ "fork-ts-checker-webpack-plugin": "3.1.1", "ignore-loader": "0.1.2", "jest-worker": "24.9.0", - "json5": "2.1.2", "jsonwebtoken": "8.5.1", "launch-editor": "2.2.1", "loader-utils": "2.0.0", @@ -193,6 +192,7 @@ "http-proxy": "1.18.0", "is-docker": "2.0.0", "is-wsl": "2.1.1", + "json5": "2.1.2", "nanoid": "2.0.3", "resolve": "1.11.0", "taskr": "1.1.0", diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 046c27c8c8..fc94fde698 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -363,6 +363,13 @@ export async function ncc_is_wsl(task, opts) { .target('dist/compiled/is-wsl') } // eslint-disable-next-line camelcase +export async function ncc_json5(task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('json5'))) + .ncc({ packageName: 'json5' }) + .target('dist/compiled/json5') +} +// eslint-disable-next-line camelcase export async function ncc_nanoid(task, opts) { await task .source(opts.src || relative(__dirname, require.resolve('nanoid'))) @@ -433,6 +440,7 @@ export async function precompile(task) { 'ncc_http_proxy', 'ncc_is_docker', 'ncc_is_wsl', + 'ncc_json5', 'ncc_nanoid', 'ncc_resolve', 'ncc_text_table', diff --git a/packages/next/types/misc.d.ts b/packages/next/types/misc.d.ts index 60a4806446..4f6ecd9bb7 100644 --- a/packages/next/types/misc.d.ts +++ b/packages/next/types/misc.d.ts @@ -116,6 +116,10 @@ declare module 'next/dist/compiled/is-wsl' { import m from 'is-wsl' export = m } +declare module 'next/dist/compiled/json5' { + import m from 'json5' + export = m +} declare module 'next/dist/compiled/nanoid/index.js' { function nanoid(size?: number): string export = nanoid