Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"regexp": "PublicPath: .*?"
},
"endsPattern": {
"regexp": "webpack compiled in .*? ms"
"regexp": "Rspack compiled in .*? s"
}
}
}
Expand Down Expand Up @@ -71,7 +71,7 @@
"regexp": "PublicPath: .*?"
},
"endsPattern": {
"regexp": "webpack compiled in .*? ms"
"regexp": "Rspack compiled in .*? s"
}
}
}
Expand Down
50 changes: 25 additions & 25 deletions build/lib/webpack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const JSONC = require('jsonc-parser');
const assert = require('assert');

Expand Down Expand Up @@ -38,43 +37,44 @@ function monorepoResourceNameMapper(packageName) {
*
* @param {string} workspaceRoot
*/
function managedPaths(workspaceRoot) {
const contents = fs.readFileSync(path.join(workspaceRoot, 'lerna.json'), 'utf-8');
/** @type {{ packages: string[] }} */
const data = JSON.parse(contents);
const patterns = data.packages;

const paths = [path.resolve(workspaceRoot, 'node_modules')];
paths.push(
...patterns
.flatMap((p) => glob.sync(p, { cwd: workspaceRoot }))
.map((p) => path.resolve(workspaceRoot, p, 'node_modules'))
);

return paths;
}
// function managedPaths(workspaceRoot) {
// const contents = fs.readFileSync(path.join(workspaceRoot, 'lerna.json'), 'utf-8');
// /** @type {{ packages: string[] }} */
// const data = JSON.parse(contents);
// const patterns = data.packages;

// const paths = [path.resolve(workspaceRoot, 'node_modules')];
// paths.push(
// ...patterns
// .flatMap((p) => glob.sync(p, { cwd: workspaceRoot }))
// .map((p) => path.resolve(workspaceRoot, p, 'node_modules'))
// );

// return paths;
// }

/**
* Builds a webpack caching config, given the calling module's __dirname and __filename.
* @param {string} dirname __dirname
* @param {string} filename __filename
* @param {string | undefined} name name of the webpack instance, if using multiple configs
* @returns {undefined}
*/
function cacheConfig(dirname, filename, name = undefined) {
// Temporarily disabled: caching breaks when switching branches,
// after typescript compilation errors, and so on.
if (true) {
return undefined;
}
return {
type: /** @type {'filesystem'} */ ('filesystem'),
cacheDirectory: path.resolve(dirname, '.webpack_cache'),
buildDependencies: {
config: [filename],
},
managedPaths: managedPaths(path.resolve(dirname, '..', '..')),
name,
};
// return {
// type: /** @type {'filesystem'} */ ('filesystem'),
// cacheDirectory: path.resolve(dirname, '.webpack_cache'),
// buildDependencies: {
// config: [filename],
// },
// managedPaths: managedPaths(path.resolve(dirname, '..', '..')),
// name,
// };
}

/**
Expand Down
Loading