diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 75aa0a8affe911bcd36d330733487c70d39fcf8c..839e2d927cfe72d4498200b57aa6c208df8259cd 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -1,5 +1,5 @@ import { join } from 'path' -import nanoid from 'nanoid' +import nanoid from 'next/dist/compiled/nanoid/index.js' import loadConfig from 'next-server/next-config' import { PHASE_PRODUCTION_BUILD } from 'next-server/constants' import getBaseWebpackConfig from './webpack-config' diff --git a/packages/next/package.json b/packages/next/package.json index 47c0f842b34499128e91ae1d9d3e4c45ab2e8453..a811872f0a2ef84a8f1b9c9981bc483b09a505e1 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -67,7 +67,6 @@ "loader-utils": "1.1.0", "magic-string": "0.25.2", "mkdirp": "0.5.1", - "nanoid": "1.2.1", "next-server": "8.0.4-canary.19", "prop-types": "15.6.2", "prop-types-exact": "1.2.0", @@ -117,6 +116,7 @@ "@types/webpack-sources": "0.1.5", "@zeit/ncc": "0.15.2", "taskr": "1.1.0", + "nanoid": "1.2.1", "text-table": "0.2.0", "typescript": "3.1.6", "unistore": "3.2.1" diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 38e444dcdd200bfd7ac5909c64facb9f972cd278..9e67ae6a7bfc0d158659c9a77925906bf1c71702 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -20,6 +20,14 @@ const babelOpts = { ] } +// eslint-disable-next-line camelcase +export async function ncc_nanoid (task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('nanoid'))) + .ncc({ packageName: 'nanoid' }) + .target('dist/compiled/nanoid') +} + // eslint-disable-next-line camelcase export async function ncc_unistore (task, opts) { await task @@ -37,7 +45,7 @@ export async function ncc_text_table (task, opts) { } export async function precompile (task) { - await task.parallel(['ncc_unistore', 'ncc_text_table']) + await task.parallel(['ncc_unistore', '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 f68b0d1fa2a4d21eba3bce9c07ba48f6a244507a..753c95bfacdb2e4cae274c21f571bac44ae12072 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -3,6 +3,13 @@ declare module 'next-server/next-config'; declare module 'next-server/constants'; declare module 'webpack/lib/GraphHelpers'; + +declare module 'next/dist/compiled/nanoid/index.js' { + function nanoid(size?: number): string; + + export = nanoid; +} + declare module 'arg' { function arg(spec: T, options?: {argv?: string[], permissive?: boolean}): arg.Result;