Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Richard van der Hoff
91c6e0e07e Move rust-sdk wasm artifact into bundles directory 2024-12-03 13:49:02 +00:00
2 changed files with 34 additions and 16 deletions

View file

@ -53,11 +53,15 @@ def move_bundles(source, dest):
renames = {} renames = {}
for f in os.listdir(source): for f in os.listdir(source):
dst = os.path.join(dest, f) dst = os.path.join(dest, f)
# If this bundle already exists, then likely the same bundle is used in multiple
# versions of the app. There's no need to copy the bundle again; however we do
# update the mtime so that the cleanup script knows that the bundle is still used.
if os.path.exists(dst): if os.path.exists(dst):
print( print(
"Skipping bundle. The bundle includes '%s' which we have previously deployed." "Skipping bundle '%s' which we have previously deployed."
% f % f
) )
os.utime(dst)
else: else:
renames[os.path.join(source, f)] = dst renames[os.path.join(source, f)] = dst

View file

@ -573,7 +573,7 @@ module.exports = (env, argv) => {
// This exports our CSS using the splitChunks and loaders above. // This exports our CSS using the splitChunks and loaders above.
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: "bundles/[fullhash]/[name].css", filename: "bundles/[fullhash]/[name].css",
chunkFilename: "bundles/[fullhash]/[name].css", chunkFilename: "bundles/[fullhash]/[name].chunk.css",
ignoreOrder: false, // Enable to remove warnings about conflicting order ignoreOrder: false, // Enable to remove warnings about conflicting order
}), }),
@ -688,16 +688,30 @@ module.exports = (env, argv) => {
output: { output: {
path: path.join(__dirname, "webapp"), path: path.join(__dirname, "webapp"),
// The generated JS (and CSS, from the extraction plugin) are put in a // There are a lot of assets that need to be kept in sync with each other
// unique subdirectory for the build. There will only be one such // (once a user loads one version of the app, they need to keep being served
// 'bundle' directory in the generated tarball; however, hosting // assets for that version).
// servers can collect 'bundles' from multiple versions into one //
// directory and symlink it into place - this allows users who loaded // To deal with this, we try to put as many as possible of the referenced assets
// an older version of the application to continue to access webpack // into a build-specific subdirectory. This includes generated javascript, as well
// chunks even after the app is redeployed. // as CSS extracted by the MiniCssExtractPlugin (see config above).
//
// Hosting servers can then collect 'bundles' from multiple versions
// into one directory, and continue to serve them even after a new version is deployed.
// This allows users who loaded an older version of the application to continue to
// access assets even after the app is redeployed.
//
// See `scripts/deploy.py` for a script which manages the deployment in this way.
filename: "bundles/[fullhash]/[name].js", filename: "bundles/[fullhash]/[name].js",
chunkFilename: "bundles/[fullhash]/[name].js", chunkFilename: "bundles/[fullhash]/[name].js",
webassemblyModuleFilename: "bundles/[fullhash]/[modulehash].wasm", webassemblyModuleFilename: "bundles/[fullhash]/[modulehash].wasm",
// Asset modules include things like the WASM for matrix-rust-sdk-crypto. Again
// these need keeping in sync with the rest of the application. Unfortunately
// `fullhash` (ie, a build-specific hash) is not available for these, so the best
// we can do is put them in their own directory. On the other hand, that does mean
// that such assets can be cached across Element versions.
assetModuleFilename: "bundles/[contenthash]/[name][ext]",
}, },
// configuration for the webpack-dev-server // configuration for the webpack-dev-server