Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

build(app): opt out of Rocket Loader, put three in its own chunk

Hampus62924347012e
diff --git a/fluxer_app/rspack.config.mjs b/fluxer_app/rspack.config.mjs
index c2e27e54e..cfbc19225 100644
--- a/fluxer_app/rspack.config.mjs
+++ b/fluxer_app/rspack.config.mjs
@@ -255,6 +255,21 @@ function authEntryDocumentPlugin() {
};
}
+function rocketLoaderOptOutPlugin() {
+ return {
+ apply(compiler) {
+ compiler.hooks.thisCompilation.tap('RocketLoaderOptOutPlugin', (compilation) => {
+ HtmlRspackPlugin.getCompilationHooks(compilation).alterAssetTags.tap('RocketLoaderOptOutPlugin', (data) => {
+ for (const tag of data.assetTags.scripts) {
+ tag.attributes = {'data-cfasync': 'false', ...tag.attributes};
+ }
+ return data;
+ });
+ });
+ },
+ };
+}
+
function fontPreloadPlugin() {
return {
apply(compiler) {
@@ -646,6 +661,7 @@ export default () => {
plugins: [
nodeAssertStrictSchemePlugin(),
fontPreloadPlugin(),
+ rocketLoaderOptOutPlugin(),
...(isProduction ? [bootPreloadPlugin()] : []),
...(isProduction && !isDesktopRenderer ? [authEntryDocumentPlugin()] : []),
new HtmlRspackPlugin({
@@ -738,6 +754,15 @@ export default () => {
enforce: true,
chunks: (chunk) => !chunk.canBeInitial() && !isWorkerPath({chunk}),
},
+ plutoniumAtom: {
+ test: /[\\/]node_modules[\\/]three[\\/]/,
+ name: 'plutonium-atom',
+ priority: 54,
+ reuseExistingChunk: true,
+ enforce: true,
+ maxAsyncSize: Number.POSITIVE_INFINITY,
+ chunks: (chunk) => !chunk.canBeInitial() && !isWorkerPath({chunk}),
+ },
editor: {
test: /[\\/]node_modules[\\/](@codemirror|@lezer|codemirror|style-mod|w3c-keyname|crelt|@marijn)[\\/]/,
name: 'editor',