Skip to content

Commit

Permalink
fix(loader): disable webpack advanced loader (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
dasein108 authored Dec 14, 2023
1 parent 4556866 commit c3d0abf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 45 deletions.
87 changes: 44 additions & 43 deletions src/components/loader/webpack-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,24 @@ class BootloaderPlugin {
);
}

const moduleNames = ['helia', 'cyb-cozo-lib-wasm'];

moduleNames.forEach((moduleName) => {
Object.keys(compilation.assets).forEach((assetName) => {
const correctedModuleName = moduleName.replace(/-/g, '_');

if (assetName.startsWith(correctedModuleName)) {
// Assuming you have a method to process these assets
this.processModuleAsset(
assetName,
compilation.assets[assetName],
htmlAssets
);
}
});
});
// const moduleNames = ['helia', 'cyb-cozo-lib-wasm'];

// moduleNames.forEach((moduleName) => {
// Object.keys(compilation.assets).forEach((assetName) => {
// const correctedModuleName = moduleName.replace(/-/g, '_');

// if (assetName.startsWith(correctedModuleName)) {
// // Assuming you have a method to process these assets
// this.processModuleAsset(
// assetName,
// compilation.assets[assetName],
// htmlAssets
// );
// }
// });
// });
});

hooks.alterAssetTags.tap('BootloaderPlugin', ({ assetTags }) => {
const entrypoint = compilation.entrypoints.get(this.options.name);
if (entrypoint) {
Expand Down Expand Up @@ -202,37 +203,37 @@ class BootloaderPlugin {
});
}

const preloadTags = htmlAssets.modules.map((moduleAsset) => {
return {
tagName: 'script',
attributes: {
src: moduleAsset.file,
type: 'text/javascript',
},
};
});
assetTags.scripts = [...preloadTags, ...assetTags.scripts];
// const preloadTags = htmlAssets.modules.map((moduleAsset) => {
// return {
// tagName: 'script',
// attributes: {
// src: moduleAsset.file,
// type: 'text/javascript',
// },
// };
// });
// assetTags.scripts = [...preloadTags, ...assetTags.scripts];
});
});
}

processModuleAsset(assetName, asset, htmlAssets) {
if (assetName.endsWith('.gz')) {
// Skip processing this asset
return;
}

// Ensure htmlAssets.modules is initialized
if (!htmlAssets.modules) {
htmlAssets.modules = [];
}

// Process the module asset and add it to htmlAssets for preloading
htmlAssets.modules.push({
file: assetName,
size: asset.size(),
});
}
// processModuleAsset(assetName, asset, htmlAssets) {
// if (assetName.endsWith('.gz')) {
// // Skip processing this asset
// return;
// }

// // Ensure htmlAssets.modules is initialized
// if (!htmlAssets.modules) {
// htmlAssets.modules = [];
// }

// // Process the module asset and add it to htmlAssets for preloading
// htmlAssets.modules.push({
// file: assetName,
// size: asset.size(),
// });
// }
}

module.exports = BootloaderPlugin;
4 changes: 2 additions & 2 deletions webpack.config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const config = {
devtool: 'cheap-module-source-map',
entry: {
main: [path.join(__dirname, 'src', 'index.tsx')],
helia: 'helia',
cozodb: 'cyb-cozo-lib-wasm',
// helia: 'helia',
// cozodb: 'cyb-cozo-lib-wasm',
},
output: {
filename: '[name].js',
Expand Down

0 comments on commit c3d0abf

Please sign in to comment.