diff --git a/packages/next/bin/next.ts b/packages/next/bin/next.ts index 5c943e82d1d90..2a3c8d8130e54 100755 --- a/packages/next/bin/next.ts +++ b/packages/next/bin/next.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import arg from 'arg' +import arg from 'next/dist/compiled/arg/index.js' ['react', 'react-dom'].forEach((dependency) => { try { diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index bd76013429473..a5ebf346f77d4 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -1,6 +1,6 @@ import path from 'path' import webpack from 'webpack' -import resolve from 'resolve' +import resolve from 'next/dist/compiled/resolve/index.js' import NextJsSsrImportPlugin from './webpack/plugins/nextjs-ssr-import' import NextJsSSRModuleCachePlugin from './webpack/plugins/nextjs-ssr-module-cache' import PagesManifestPlugin from './webpack/plugins/pages-manifest-plugin' diff --git a/packages/next/cli/next-build.ts b/packages/next/cli/next-build.ts index bca677c9cac0d..5d05dab451c4f 100755 --- a/packages/next/cli/next-build.ts +++ b/packages/next/cli/next-build.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { resolve, join } from 'path' import { existsSync } from 'fs' -import arg from 'arg' +import arg from 'next/dist/compiled/arg/index.js' import build from '../build' import { printAndExit } from '../server/lib/utils' import { cliCommand } from '../bin/next' diff --git a/packages/next/cli/next-dev.ts b/packages/next/cli/next-dev.ts index f2774be498748..08673d56ed7a0 100755 --- a/packages/next/cli/next-dev.ts +++ b/packages/next/cli/next-dev.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node import { resolve, join } from 'path' -import arg from 'arg' +import arg from 'next/dist/compiled/arg/index.js' import { existsSync } from 'fs' import startServer from '../server/lib/start-server' import { printAndExit } from '../server/lib/utils' diff --git a/packages/next/cli/next-export.ts b/packages/next/cli/next-export.ts index 6c1a78512c582..7465e12b74bc3 100755 --- a/packages/next/cli/next-export.ts +++ b/packages/next/cli/next-export.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { resolve, join } from 'path' import { existsSync } from 'fs' -import arg from 'arg' +import arg from 'next/dist/compiled/arg/index.js' import exportApp from '../export' import { printAndExit } from '../server/lib/utils' import { cliCommand } from '../bin/next' diff --git a/packages/next/cli/next-start.ts b/packages/next/cli/next-start.ts index ad28cfaaddceb..49b73e13891bd 100755 --- a/packages/next/cli/next-start.ts +++ b/packages/next/cli/next-start.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { resolve } from 'path' -import arg from 'arg' +import arg from 'next/dist/compiled/arg/index.js' import startServer from '../server/lib/start-server' import { cliCommand } from '../bin/next' diff --git a/packages/next/package.json b/packages/next/package.json index 85bd6e71140d6..e56d8d99dc3fc 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -49,9 +49,7 @@ "@babel/preset-react": "7.0.0", "@babel/runtime": "7.1.2", "@babel/runtime-corejs2": "7.1.2", - "@babel/template": "7.1.2", "amphtml-validator": "1.0.23", - "arg": "3.0.0", "async-sema": "2.2.0", "autodll-webpack-plugin": "0.4.2", "babel-core": "7.0.0-bridge.0", @@ -73,7 +71,6 @@ "react-error-overlay": "5.1.4", "react-is": "16.6.3", "recursive-copy": "2.0.6", - "resolve": "1.5.0", "serialize-javascript": "1.6.1", "source-map": "0.6.1", "strip-ansi": "3.0.1", @@ -93,6 +90,7 @@ "react-dom": "^16.6.0" }, "devDependencies": { + "resolve": "1.5.0", "@babel/parser": "7.2.0", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", @@ -115,6 +113,7 @@ "@types/text-table": "0.2.0", "@types/webpack-sources": "0.1.5", "@zeit/ncc": "0.15.2", + "arg": "4.1.0", "nanoid": "1.2.1", "taskr": "1.1.0", "text-table": "0.2.0", diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 9e67ae6a7bfc0..610aff3e780b5 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -20,6 +20,22 @@ const babelOpts = { ] } +// eslint-disable-next-line camelcase +export async function ncc_arg (task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('arg'))) + .ncc({ packageName: 'arg' }) + .target('dist/compiled/arg') +} + +// eslint-disable-next-line camelcase +export async function ncc_resolve (task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('resolve'))) + .ncc({ packageName: 'resolve' }) + .target('dist/compiled/resolve') +} + // eslint-disable-next-line camelcase export async function ncc_nanoid (task, opts) { await task @@ -45,7 +61,7 @@ export async function ncc_text_table (task, opts) { } export async function precompile (task) { - await task.parallel(['ncc_unistore', 'ncc_nanoid', 'ncc_text_table']) + await task.parallel(['ncc_unistore', 'ncc_resolve', 'ncc_arg', 'ncc_nanoid', 'ncc_text_table']) } export async function compile (task) { diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index 753c95bfacdb2..299f10b0647db 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -10,7 +10,13 @@ declare module 'next/dist/compiled/nanoid/index.js' { export = nanoid; } -declare module 'arg' { +declare module 'next/dist/compiled/resolve/index.js' { + import resolve from 'resolve' + + export = resolve; +} + +declare module 'next/dist/compiled/arg/index.js' { function arg(spec: T, options?: {argv?: string[], permissive?: boolean}): arg.Result; namespace arg { @@ -33,6 +39,7 @@ declare module 'arg' { export = arg; } + declare module 'autodll-webpack-plugin' { import webpack from 'webpack' class AutoDllPlugin implements webpack.Plugin { diff --git a/yarn.lock b/yarn.lock index f4c43d8a6425d..2a8ba35bb8c4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -735,15 +735,6 @@ dependencies: regenerator-runtime "^0.12.0" -"@babel/template@7.1.2": - version "7.1.2" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.1.2.tgz#090484a574fef5a2d2d7726a674eceda5c5b5644" - integrity sha512-SY1MmplssORfFiLDcOETrW7fCLl+PavlwMh92rrGcikQaRq4iWPVH0MpwPpY3etVMx6RnDjXtr6VZYr/IbP/Ag== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.1.2" - "@babel/types" "^7.1.2" - "@babel/template@^7.1.0", "@babel/template@^7.1.2", "@babel/template@^7.2.2": version "7.2.2" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907" @@ -2204,10 +2195,10 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" -arg@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/arg/-/arg-3.0.0.tgz#386c20035dfbeb13e280ca8a1e6868aa17942def" - integrity sha512-C5Scb477yHhNck9AFzW5RwAzS2Eqn0HR+Fv0pmcZBXBT8g/g7OOuZTr0upVSSUGWZQH+XWdAKIw2OfC86EuggQ== +arg@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0" + integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg== argparse@^1.0.7: version "1.0.10"