chore: update to webpack v5 (#1967)

The bundle size has decreased slightly, so I really can't complain.
This commit is contained in:
Nolan Lawson 2021-02-20 15:30:58 -08:00 committed by GitHub
parent 2c34527411
commit b2583277eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 266 additions and 1307 deletions

View file

@ -84,7 +84,7 @@
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^7.0.2",
"rtl-detect": "^1.0.2",
"sapper": "nolanlawson/sapper#for-pinafore-22",
"sapper": "nolanlawson/sapper#for-pinafore-24",
"sass": "^1.32.8",
"stringz": "^2.1.0",
"svelte": "^2.16.1",
@ -92,12 +92,12 @@
"svelte-loader": "^2.13.6",
"svelte-transitions": "^1.2.0",
"svgo": "^1.3.2",
"terser-webpack-plugin": "^4.2.3",
"terser-webpack-plugin": "^5.1.1",
"tesseract.js": "^2.1.4",
"tesseract.js-core": "^2.2.0",
"text-encoding": "^0.7.0",
"tiny-queue": "^0.2.1",
"webpack": "^4.46.0",
"webpack": "^5.23.0",
"webpack-bundle-analyzer": "^4.4.0",
"worker-loader": "^3.0.8"
},

View file

@ -10,7 +10,7 @@
<script>
import SettingsLayout from '../../_components/settings/SettingsLayout.html'
import { version } from '../../../../package.json'
const version = process.env.PINAFORE_VERSION
export default {
components: {

View file

@ -8,19 +8,27 @@ const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
const terser = require('./terser.config')
const CircularDependencyPlugin = require('circular-dependency-plugin')
const { mode, dev, resolve, inlineSvgs, allSvgs } = require('./shared.config')
const { version } = require('../package.json')
const urlRegex = require('../src/routes/_utils/urlRegexSource.js')()
const output = Object.assign(config.client.output(), {
// enables HMR in workers
globalObject: 'this',
filename: dev ? '[hash]/[id].js' : '[id].[contenthash].[name].js',
chunkFilename: dev ? '[hash]/[id].js' : '[id].[contenthash].[name].js'
filename: dev ? '[fullhash]/[id].js' : '[id].[contenthash].[name].js',
chunkFilename: dev ? '[fullhash]/[id].js' : '[id].[contenthash].[name].js'
})
const emojiPickerI18n = LOCALE !== DEFAULT_LOCALE &&
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 = {
entry: config.client.entry(),
output,
@ -33,7 +41,7 @@ module.exports = {
use: {
loader: 'worker-loader',
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: {
loader: 'file-loader',
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)
},
node: {
setImmediate: false
},
optimization: dev
? {}
: {
@ -105,7 +110,8 @@ module.exports = {
'process.env.ALL_SVGS': JSON.stringify(allSvgs),
'process.env.URL_REGEX': urlRegex.toString(),
'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(
/\/_database\/database\.js$/, // this version plays nicer with IDEs

View file

@ -5,6 +5,7 @@ const webpack = require('webpack')
const config = require('sapper/config/webpack.js')
const pkg = require('../package.json')
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
// (because they're only used on the client side)
@ -65,7 +66,8 @@ module.exports = {
new webpack.DefinePlugin({
'process.env.INLINE_SVGS': JSON.stringify(inlineSvgs),
'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)
})
]
}

View file

@ -3,8 +3,6 @@ const terserOptions = require('../bin/terserOptions')
module.exports = () => new TerserWebpackPlugin({
exclude: /(tesseract-asset|page-lifecycle)/, // tesseract causes problems, page-lifecycle is pre-minified
cache: !process.env.TERSER_DISABLE_CACHE,
parallel: true,
sourceMap: true,
terserOptions
})

1537
yarn.lock

File diff suppressed because it is too large Load diff