diff --git a/packages/next/build/webpack-config.js b/packages/next/build/webpack-config.js index aad8f861..e664b0f5 100644 --- a/packages/next/build/webpack-config.js +++ b/packages/next/build/webpack-config.js @@ -13,7 +13,7 @@ import BuildManifestPlugin from './webpack/plugins/build-manifest-plugin' import ChunkNamesPlugin from './webpack/plugins/chunk-names-plugin' import { ReactLoadablePlugin } from './webpack/plugins/react-loadable-plugin' import {SERVER_DIRECTORY, REACT_LOADABLE_MANIFEST, CLIENT_STATIC_FILES_RUNTIME_WEBPACK, CLIENT_STATIC_FILES_RUNTIME_MAIN} from 'next-server/constants' -import {NEXT_PROJECT_ROOT, NEXT_PROJECT_ROOT_NODE_MODULES, NEXT_PROJECT_ROOT_DIST_CLIENT, DEFAULT_PAGES_DIR, PAGES_DIR_ALIAS, DOT_NEXT_ALIAS} from '../lib/constants' +import {NEXT_PROJECT_ROOT, NEXT_PROJECT_ROOT_NODE_MODULES, NEXT_PROJECT_ROOT_DIST_CLIENT, PAGES_DIR_ALIAS, DOT_NEXT_ALIAS} from '../lib/constants' import AutoDllPlugin from 'autodll-webpack-plugin' import TerserPlugin from 'terser-webpack-plugin' import AssetsSizePlugin from './webpack/plugins/assets-size-plugin' @@ -232,9 +232,9 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer rules: [ { test: /\.(js|jsx)$/, - include: [dir, NEXT_PROJECT_ROOT_DIST_CLIENT, DEFAULT_PAGES_DIR, /next-server[\\/]dist[\\/]lib/], + include: [dir, /next-server[\\/]dist[\\/]lib/], exclude: (path) => { - if (path.indexOf(NEXT_PROJECT_ROOT_DIST_CLIENT) === 0 || path.indexOf(DEFAULT_PAGES_DIR) === 0 || /next-server[\\/]dist[\\/]lib/.exec(path)) { + if (/next-server[\\/]dist[\\/]lib/.exec(path)) { return false } diff --git a/packages/next/taskfile-typescript.js b/packages/next/taskfile-typescript.js index 185c06cb..93dd83f7 100644 --- a/packages/next/taskfile-typescript.js +++ b/packages/next/taskfile-typescript.js @@ -36,6 +36,9 @@ try { }) } + // Workaround for noop.js loading + if (file.base === 'next-dev.js') result.outputText = result.outputText.replace(/Promise\.resolve\(\)\.then\(\(\) => __importStar\(require\('\.\/noop'\)\)\);/, `import('./noop');`) + // update file's data file.data = Buffer.from(result.outputText.replace(/process\.env\.NEXT_VERSION/, `"${require('./package.json').version}"`), 'utf8') }) diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index da6fef5a..c5e8caba 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -25,7 +25,7 @@ export async function nextbuild (task, opts) { } export async function client (task, opts) { - await task.source(opts.src || 'client/**/*.+(js|ts|tsx)').typescript().target('dist/client') + await task.source(opts.src || 'client/**/*.+(js|ts|tsx)').typescript({module: 'commonjs', target: 'es5'}).target('dist/client') notify('Compiled client files') } @@ -36,7 +36,7 @@ export async function nextbuildstatic (task, opts) { } export async function pages (task, opts) { - await task.source(opts.src || 'pages/**/*.+(js|ts|tsx)').typescript().target('dist/pages') + await task.source(opts.src || 'pages/**/*.+(js|ts|tsx)').typescript({module: 'commonjs', target: 'es5'}).target('dist/pages') } export async function build (task) {