mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
remove dll support
webpack 4 is more faster and dll is problematic and unstable.
This commit is contained in:
parent
11280681d1
commit
23c11b1cef
@ -23,7 +23,6 @@ const {
|
|||||||
const { Options } = require('../common')
|
const { Options } = require('../common')
|
||||||
const clientWebpackConfig = require('./webpack/client.config.js')
|
const clientWebpackConfig = require('./webpack/client.config.js')
|
||||||
const serverWebpackConfig = require('./webpack/server.config.js')
|
const serverWebpackConfig = require('./webpack/server.config.js')
|
||||||
const dllWebpackConfig = require('./webpack/dll.config.js')
|
|
||||||
const upath = require('upath')
|
const upath = require('upath')
|
||||||
|
|
||||||
const debug = Debug('nuxt:build')
|
const debug = Debug('nuxt:build')
|
||||||
@ -95,21 +94,6 @@ module.exports = class Builder {
|
|||||||
.filter(v => v)
|
.filter(v => v)
|
||||||
}
|
}
|
||||||
|
|
||||||
vendorEntries() {
|
|
||||||
// Used for dll
|
|
||||||
const vendor = this.vendor()
|
|
||||||
const vendorEntries = {}
|
|
||||||
vendor.forEach(v => {
|
|
||||||
try {
|
|
||||||
require.resolve(v)
|
|
||||||
vendorEntries[v] = [v]
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return vendorEntries
|
|
||||||
}
|
|
||||||
|
|
||||||
forGenerate() {
|
forGenerate() {
|
||||||
this.isStatic = true
|
this.isStatic = true
|
||||||
}
|
}
|
||||||
@ -510,11 +494,6 @@ module.exports = class Builder {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Make a dll plugin after compile to make nuxt dev builds faster
|
|
||||||
if (this.options.build.dll && this.options.dev) {
|
|
||||||
compilersOptions.push(dllWebpackConfig.call(this, clientConfig))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize shared FS and Cache
|
// Initialize shared FS and Cache
|
||||||
const sharedFS = this.options.dev && new MFS()
|
const sharedFS = this.options.dev && new MFS()
|
||||||
const sharedCache = {}
|
const sharedCache = {}
|
||||||
@ -522,8 +501,8 @@ module.exports = class Builder {
|
|||||||
// Initialize compilers
|
// Initialize compilers
|
||||||
this.compilers = compilersOptions.map(compilersOption => {
|
this.compilers = compilersOptions.map(compilersOption => {
|
||||||
const compiler = webpack(compilersOption)
|
const compiler = webpack(compilersOption)
|
||||||
// In dev, write files in memory FS (except for DLL)
|
// In dev, write files in memory FS
|
||||||
if (sharedFS && !compiler.name.includes('-dll')) {
|
if (sharedFS) {
|
||||||
compiler.outputFileSystem = sharedFS
|
compiler.outputFileSystem = sharedFS
|
||||||
}
|
}
|
||||||
compiler.cache = sharedCache
|
compiler.cache = sharedCache
|
||||||
@ -556,14 +535,6 @@ module.exports = class Builder {
|
|||||||
if (compiler.options.name === 'client') {
|
if (compiler.options.name === 'client') {
|
||||||
return this.webpackDev(compiler)
|
return this.webpackDev(compiler)
|
||||||
}
|
}
|
||||||
// DLL build, should run only once
|
|
||||||
if (compiler.options.name.includes('-dll')) {
|
|
||||||
compiler.run((err, stats) => {
|
|
||||||
if (err) return reject(err)
|
|
||||||
debug('[DLL] updated')
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// Server, build and watch for changes
|
// Server, build and watch for changes
|
||||||
this.compilersWatching.push(
|
this.compilersWatching.push(
|
||||||
compiler.watch(this.options.watchers.webpack, err => {
|
compiler.watch(this.options.watchers.webpack, err => {
|
||||||
|
@ -127,11 +127,6 @@ module.exports = function webpackClientConfig() {
|
|||||||
|
|
||||||
// HMR
|
// HMR
|
||||||
config.plugins.push(new webpack.HotModuleReplacementPlugin())
|
config.plugins.push(new webpack.HotModuleReplacementPlugin())
|
||||||
|
|
||||||
// DllReferencePlugin
|
|
||||||
if (this.options.build.dll) {
|
|
||||||
dllPlugin.call(this, config)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------
|
// --------------------------------------
|
||||||
@ -204,28 +199,3 @@ module.exports = function webpackClientConfig() {
|
|||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// Adds DLL plugin
|
|
||||||
// https://github.com/webpack/webpack/tree/master/examples/dll-user
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
function dllPlugin(config) {
|
|
||||||
const _dlls = []
|
|
||||||
const vendorEntries = this.vendorEntries()
|
|
||||||
const dllDir = resolve(this.options.cacheDir, config.name + '-dll')
|
|
||||||
Object.keys(vendorEntries).forEach(v => {
|
|
||||||
const dllManifestFile = resolve(dllDir, v + '-manifest.json')
|
|
||||||
if (existsSync(dllManifestFile)) {
|
|
||||||
_dlls.push(v)
|
|
||||||
config.plugins.push(
|
|
||||||
new webpack.DllReferencePlugin({
|
|
||||||
// context: this.options.rootDir,
|
|
||||||
manifest: dllManifestFile // Using full path to allow finding .js dll file
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (_dlls.length) {
|
|
||||||
debug('Using dll for ' + _dlls.join(','))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
const webpack = require('webpack')
|
|
||||||
const { resolve } = require('path')
|
|
||||||
const ClientConfig = require('./client.config')
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Webpack Dll Config
|
|
||||||
| https://github.com/webpack/webpack/tree/master/examples/dll
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
module.exports = function webpackDllConfig(_refConfig) {
|
|
||||||
const refConfig = _refConfig || new ClientConfig()
|
|
||||||
|
|
||||||
const name = refConfig.name + '-dll'
|
|
||||||
const dllDir = resolve(this.options.cacheDir, name)
|
|
||||||
|
|
||||||
let config = {
|
|
||||||
name,
|
|
||||||
entry: this.vendorEntries(),
|
|
||||||
// context: this.options.rootDir,
|
|
||||||
resolve: refConfig.resolve,
|
|
||||||
target: refConfig.target,
|
|
||||||
resolveLoader: refConfig.resolveLoader,
|
|
||||||
module: refConfig.module,
|
|
||||||
plugins: []
|
|
||||||
}
|
|
||||||
|
|
||||||
config.output = {
|
|
||||||
path: dllDir,
|
|
||||||
filename: '[name]_[hash].js',
|
|
||||||
library: '[name]_[hash]'
|
|
||||||
}
|
|
||||||
|
|
||||||
config.plugins.push(
|
|
||||||
new webpack.DllPlugin({
|
|
||||||
// The path to the manifest file which maps between
|
|
||||||
// modules included in a bundle and the internal IDs
|
|
||||||
// within that bundle
|
|
||||||
path: resolve(dllDir, '[name]-manifest.json'),
|
|
||||||
|
|
||||||
name: '[name]_[hash]'
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
return config
|
|
||||||
}
|
|
@ -187,7 +187,6 @@ Options.defaults = {
|
|||||||
build: {
|
build: {
|
||||||
analyze: false,
|
analyze: false,
|
||||||
profile: process.argv.includes('--profile'),
|
profile: process.argv.includes('--profile'),
|
||||||
dll: false,
|
|
||||||
maxChunkSize: false,
|
maxChunkSize: false,
|
||||||
extractCSS: false,
|
extractCSS: false,
|
||||||
cssSourceMap: undefined,
|
cssSourceMap: undefined,
|
||||||
@ -329,9 +328,7 @@ Options.defaults = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watchers: {
|
watchers: {
|
||||||
webpack: {
|
webpack: {},
|
||||||
ignored: /-dll/
|
|
||||||
},
|
|
||||||
chokidar: {}
|
chokidar: {}
|
||||||
},
|
},
|
||||||
editor: undefined,
|
editor: undefined,
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
import { promisify } from 'util'
|
|
||||||
import test from 'ava'
|
|
||||||
import { resolve } from 'path'
|
|
||||||
import fs from 'fs'
|
|
||||||
import { Nuxt, Builder } from '..'
|
|
||||||
import { interceptLog, release } from './helpers/console'
|
|
||||||
|
|
||||||
const readFile = promisify(fs.readFile)
|
|
||||||
const rootDir = resolve(__dirname, 'fixtures/dll')
|
|
||||||
const dllDir = resolve(rootDir, '.cache/client-dll')
|
|
||||||
|
|
||||||
const checkCache = lib => {
|
|
||||||
return async t => {
|
|
||||||
const manifest = await readFile(
|
|
||||||
resolve(dllDir, `./${lib}-manifest.json`),
|
|
||||||
'utf-8'
|
|
||||||
)
|
|
||||||
t.truthy(JSON.parse(manifest).name)
|
|
||||||
t.true(fs.existsSync(resolve(dllDir, `./${JSON.parse(manifest).name}.js`)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let nuxt
|
|
||||||
|
|
||||||
test.serial('Init Nuxt.js', async t => {
|
|
||||||
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
|
||||||
config.rootDir = rootDir
|
|
||||||
config.dev = true
|
|
||||||
|
|
||||||
const logSpy = await interceptLog(async () => {
|
|
||||||
nuxt = new Nuxt(config)
|
|
||||||
await new Builder(nuxt).build()
|
|
||||||
})
|
|
||||||
t.true(logSpy.calledWithMatch('DONE'))
|
|
||||||
})
|
|
||||||
|
|
||||||
test('Check vue cache', checkCache('vue'))
|
|
||||||
|
|
||||||
test('Check vue-meta cache', checkCache('vue-meta'))
|
|
||||||
|
|
||||||
test('Check vue-router cache', checkCache('vue-router'))
|
|
||||||
|
|
||||||
test('Build with DllReferencePlugin', async t => {
|
|
||||||
const logSpy = await interceptLog()
|
|
||||||
await new Builder(nuxt).build()
|
|
||||||
release()
|
|
||||||
t.true(logSpy.withArgs('Using dll for 3 libs').calledOnce)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Close server and ask nuxt to stop listening to file changes
|
|
||||||
test.after.always('Closing nuxt.js', t => {
|
|
||||||
nuxt.close()
|
|
||||||
})
|
|
15
test/fixtures/dll/nuxt.config.js
vendored
15
test/fixtures/dll/nuxt.config.js
vendored
@ -1,15 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
build: {
|
|
||||||
stats: false,
|
|
||||||
dll: true,
|
|
||||||
extend(config, options) {
|
|
||||||
if (options.isClient) {
|
|
||||||
const dlls = config.plugins.filter(
|
|
||||||
plugin => plugin.constructor.name === 'DllReferencePlugin'
|
|
||||||
)
|
|
||||||
console.log('Using dll for ' + dlls.length + ' libs') // eslint-disable-line no-console
|
|
||||||
}
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
0
test/fixtures/dll/pages/index.vue
vendored
0
test/fixtures/dll/pages/index.vue
vendored
Loading…
Reference in New Issue
Block a user