chore: update to webpack v5 (#1967)
The bundle size has decreased slightly, so I really can't complain.
This commit is contained in:
parent
2c34527411
commit
b2583277eb
|
@ -84,7 +84,7 @@
|
||||||
"rollup-plugin-babel": "^4.4.0",
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"rtl-detect": "^1.0.2",
|
"rtl-detect": "^1.0.2",
|
||||||
"sapper": "nolanlawson/sapper#for-pinafore-22",
|
"sapper": "nolanlawson/sapper#for-pinafore-24",
|
||||||
"sass": "^1.32.8",
|
"sass": "^1.32.8",
|
||||||
"stringz": "^2.1.0",
|
"stringz": "^2.1.0",
|
||||||
"svelte": "^2.16.1",
|
"svelte": "^2.16.1",
|
||||||
|
@ -92,12 +92,12 @@
|
||||||
"svelte-loader": "^2.13.6",
|
"svelte-loader": "^2.13.6",
|
||||||
"svelte-transitions": "^1.2.0",
|
"svelte-transitions": "^1.2.0",
|
||||||
"svgo": "^1.3.2",
|
"svgo": "^1.3.2",
|
||||||
"terser-webpack-plugin": "^4.2.3",
|
"terser-webpack-plugin": "^5.1.1",
|
||||||
"tesseract.js": "^2.1.4",
|
"tesseract.js": "^2.1.4",
|
||||||
"tesseract.js-core": "^2.2.0",
|
"tesseract.js-core": "^2.2.0",
|
||||||
"text-encoding": "^0.7.0",
|
"text-encoding": "^0.7.0",
|
||||||
"tiny-queue": "^0.2.1",
|
"tiny-queue": "^0.2.1",
|
||||||
"webpack": "^4.46.0",
|
"webpack": "^5.23.0",
|
||||||
"webpack-bundle-analyzer": "^4.4.0",
|
"webpack-bundle-analyzer": "^4.4.0",
|
||||||
"worker-loader": "^3.0.8"
|
"worker-loader": "^3.0.8"
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<script>
|
<script>
|
||||||
import SettingsLayout from '../../_components/settings/SettingsLayout.html'
|
import SettingsLayout from '../../_components/settings/SettingsLayout.html'
|
||||||
|
|
||||||
import { version } from '../../../../package.json'
|
const version = process.env.PINAFORE_VERSION
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -8,19 +8,27 @@ const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
|
||||||
const terser = require('./terser.config')
|
const terser = require('./terser.config')
|
||||||
const CircularDependencyPlugin = require('circular-dependency-plugin')
|
const CircularDependencyPlugin = require('circular-dependency-plugin')
|
||||||
const { mode, dev, resolve, inlineSvgs, allSvgs } = require('./shared.config')
|
const { mode, dev, resolve, inlineSvgs, allSvgs } = require('./shared.config')
|
||||||
|
const { version } = require('../package.json')
|
||||||
|
|
||||||
const urlRegex = require('../src/routes/_utils/urlRegexSource.js')()
|
const urlRegex = require('../src/routes/_utils/urlRegexSource.js')()
|
||||||
|
|
||||||
const output = Object.assign(config.client.output(), {
|
const output = Object.assign(config.client.output(), {
|
||||||
// enables HMR in workers
|
// enables HMR in workers
|
||||||
globalObject: 'this',
|
globalObject: 'this',
|
||||||
filename: dev ? '[hash]/[id].js' : '[id].[contenthash].[name].js',
|
filename: dev ? '[fullhash]/[id].js' : '[id].[contenthash].[name].js',
|
||||||
chunkFilename: dev ? '[hash]/[id].js' : '[id].[contenthash].[name].js'
|
chunkFilename: dev ? '[fullhash]/[id].js' : '[id].[contenthash].[name].js'
|
||||||
})
|
})
|
||||||
|
|
||||||
const emojiPickerI18n = LOCALE !== DEFAULT_LOCALE &&
|
const emojiPickerI18n = LOCALE !== DEFAULT_LOCALE &&
|
||||||
require(path.join(__dirname, '../src/intl/emoji-picker/', `${LOCALE}.js`)).default
|
require(path.join(__dirname, '../src/intl/emoji-picker/', `${LOCALE}.js`)).default
|
||||||
|
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
// TODO: seems to be a Webpack Bundle Analyzer error we can safely ignore
|
||||||
|
if (!err.message.includes('Error: No such label \'done hook\' for WebpackLogger.timeEnd()')) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: config.client.entry(),
|
entry: config.client.entry(),
|
||||||
output,
|
output,
|
||||||
|
@ -33,7 +41,7 @@ module.exports = {
|
||||||
use: {
|
use: {
|
||||||
loader: 'worker-loader',
|
loader: 'worker-loader',
|
||||||
options: {
|
options: {
|
||||||
filename: dev ? '[hash]/blurhash.[name].js' : 'blurhash.[contenthash].[name].js'
|
filename: dev ? '[fullhash]/blurhash.[name].js' : 'blurhash.[contenthash].[name].js'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -47,7 +55,7 @@ module.exports = {
|
||||||
use: {
|
use: {
|
||||||
loader: 'file-loader',
|
loader: 'file-loader',
|
||||||
options: {
|
options: {
|
||||||
name: dev ? '[hash]/tesseract-asset.[name].[ext]' : 'tesseract-asset.[contenthash].[name].[ext]'
|
name: dev ? '[fullhash]/tesseract-asset.[name].[ext]' : 'tesseract-asset.[contenthash].[name].[ext]'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -77,9 +85,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
].filter(Boolean)
|
].filter(Boolean)
|
||||||
},
|
},
|
||||||
node: {
|
|
||||||
setImmediate: false
|
|
||||||
},
|
|
||||||
optimization: dev
|
optimization: dev
|
||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
|
@ -105,7 +110,8 @@ module.exports = {
|
||||||
'process.env.ALL_SVGS': JSON.stringify(allSvgs),
|
'process.env.ALL_SVGS': JSON.stringify(allSvgs),
|
||||||
'process.env.URL_REGEX': urlRegex.toString(),
|
'process.env.URL_REGEX': urlRegex.toString(),
|
||||||
'process.env.LOCALE': JSON.stringify(LOCALE),
|
'process.env.LOCALE': JSON.stringify(LOCALE),
|
||||||
'process.env.EMOJI_PICKER_I18N': emojiPickerI18n ? JSON.stringify(emojiPickerI18n) : 'undefined'
|
'process.env.EMOJI_PICKER_I18N': emojiPickerI18n ? JSON.stringify(emojiPickerI18n) : 'undefined',
|
||||||
|
'process.env.PINAFORE_VERSION': JSON.stringify(version)
|
||||||
}),
|
}),
|
||||||
new webpack.NormalModuleReplacementPlugin(
|
new webpack.NormalModuleReplacementPlugin(
|
||||||
/\/_database\/database\.js$/, // this version plays nicer with IDEs
|
/\/_database\/database\.js$/, // this version plays nicer with IDEs
|
||||||
|
|
|
@ -5,6 +5,7 @@ const webpack = require('webpack')
|
||||||
const config = require('sapper/config/webpack.js')
|
const config = require('sapper/config/webpack.js')
|
||||||
const pkg = require('../package.json')
|
const pkg = require('../package.json')
|
||||||
const { mode, dev, resolve, inlineSvgs, allSvgs } = require('./shared.config')
|
const { mode, dev, resolve, inlineSvgs, allSvgs } = require('./shared.config')
|
||||||
|
const { version } = require('../package.json')
|
||||||
|
|
||||||
// modules that the server should ignore, either because they cause errors or warnings
|
// modules that the server should ignore, either because they cause errors or warnings
|
||||||
// (because they're only used on the client side)
|
// (because they're only used on the client side)
|
||||||
|
@ -65,7 +66,8 @@ module.exports = {
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env.INLINE_SVGS': JSON.stringify(inlineSvgs),
|
'process.env.INLINE_SVGS': JSON.stringify(inlineSvgs),
|
||||||
'process.env.ALL_SVGS': JSON.stringify(allSvgs),
|
'process.env.ALL_SVGS': JSON.stringify(allSvgs),
|
||||||
'process.env.LOCALE': JSON.stringify(LOCALE)
|
'process.env.LOCALE': JSON.stringify(LOCALE),
|
||||||
|
'process.env.PINAFORE_VERSION': JSON.stringify(version)
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ const terserOptions = require('../bin/terserOptions')
|
||||||
|
|
||||||
module.exports = () => new TerserWebpackPlugin({
|
module.exports = () => new TerserWebpackPlugin({
|
||||||
exclude: /(tesseract-asset|page-lifecycle)/, // tesseract causes problems, page-lifecycle is pre-minified
|
exclude: /(tesseract-asset|page-lifecycle)/, // tesseract causes problems, page-lifecycle is pre-minified
|
||||||
cache: !process.env.TERSER_DISABLE_CACHE,
|
|
||||||
parallel: true,
|
parallel: true,
|
||||||
sourceMap: true,
|
|
||||||
terserOptions
|
terserOptions
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue