mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Compile next/client and next/pages (#6019)
Because next-routes requires APIs outside of compilation we have to compile these Fixes https://github.com/fridays/next-routes/issues/274 Fixes #6017
This commit is contained in:
parent
25fb3f9c2e
commit
2e9ff91372
|
@ -13,7 +13,7 @@ import BuildManifestPlugin from './webpack/plugins/build-manifest-plugin'
|
||||||
import ChunkNamesPlugin from './webpack/plugins/chunk-names-plugin'
|
import ChunkNamesPlugin from './webpack/plugins/chunk-names-plugin'
|
||||||
import { ReactLoadablePlugin } from './webpack/plugins/react-loadable-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 {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 AutoDllPlugin from 'autodll-webpack-plugin'
|
||||||
import TerserPlugin from 'terser-webpack-plugin'
|
import TerserPlugin from 'terser-webpack-plugin'
|
||||||
import AssetsSizePlugin from './webpack/plugins/assets-size-plugin'
|
import AssetsSizePlugin from './webpack/plugins/assets-size-plugin'
|
||||||
|
@ -232,9 +232,9 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.(js|jsx)$/,
|
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) => {
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// update file's data
|
||||||
file.data = Buffer.from(result.outputText.replace(/process\.env\.NEXT_VERSION/, `"${require('./package.json').version}"`), 'utf8')
|
file.data = Buffer.from(result.outputText.replace(/process\.env\.NEXT_VERSION/, `"${require('./package.json').version}"`), 'utf8')
|
||||||
})
|
})
|
||||||
|
|
|
@ -25,7 +25,7 @@ export async function nextbuild (task, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function client (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')
|
notify('Compiled client files')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ export async function nextbuildstatic (task, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function pages (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) {
|
export async function build (task) {
|
||||||
|
|
Loading…
Reference in a new issue