@shuvi/toolpack 2.0.0-dev.15 → 2.0.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -43,6 +43,7 @@ const path = __importStar(require("path"));
|
|
|
43
43
|
const fs = __importStar(require("fs"));
|
|
44
44
|
const constants_1 = require("@shuvi/shared/constants");
|
|
45
45
|
const fix_watching_plugin_1 = __importDefault(require("../plugins/fix-watching-plugin"));
|
|
46
|
+
const crypto = __importStar(require("crypto"));
|
|
46
47
|
const resolveLocalLoader = (name) => path.join(__dirname, `../loaders/${name}`);
|
|
47
48
|
function getDefineEnv(env) {
|
|
48
49
|
return Object.assign(Object.assign({}, Object.keys(process.env).reduce((prev, key) => {
|
|
@@ -221,35 +222,41 @@ function baseRspackChain({ dev, outputDir, lightningCss, compiler, projectRoot,
|
|
|
221
222
|
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production')
|
|
222
223
|
}
|
|
223
224
|
]);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
225
|
+
const getCacheConfig = () => {
|
|
226
|
+
const projectHash = crypto
|
|
227
|
+
.createHash('md5')
|
|
228
|
+
.update(projectRoot)
|
|
229
|
+
.digest('hex');
|
|
230
|
+
const stringifiedEnvs = Object.entries(Object.assign({}, getDefineEnv(env))).reduce((prev, [key, value]) => {
|
|
231
|
+
return `${prev}|${key}=${value}`;
|
|
232
|
+
}, '');
|
|
233
|
+
const PACKAGE_JSON = path.resolve(__dirname, '../../../package.json');
|
|
234
|
+
const SHUVI_VERSION = require(PACKAGE_JSON).version;
|
|
235
|
+
return {
|
|
236
|
+
cacheDirectory: path.join(cacheDir, 'rspack', projectHash),
|
|
237
|
+
type: 'filesystem',
|
|
238
|
+
name: `${name.replace(/\//, '-')}-${config.get('mode')}`,
|
|
239
|
+
version: `${SHUVI_VERSION}|${stringifiedEnvs}`
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
// Enable filesystem cache for Rspack using experiments.cache
|
|
243
|
+
if (typeof process.env.SHUVI_DEV_DISABLE_CACHE === 'undefined') {
|
|
244
|
+
const cacheConfig = getCacheConfig();
|
|
245
|
+
config.cache(true);
|
|
246
|
+
config.set('experiments', {
|
|
247
|
+
cache: {
|
|
248
|
+
type: 'persistent',
|
|
249
|
+
version: cacheConfig.version,
|
|
250
|
+
storage: {
|
|
251
|
+
type: 'filesystem',
|
|
252
|
+
directory: cacheConfig.cacheDirectory
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
config.cache(false);
|
|
259
|
+
}
|
|
253
260
|
const tsConfigPath = path.join(projectRoot, 'tsconfig.json');
|
|
254
261
|
const jsConfigPath = path.join(projectRoot, 'jsconfig.json');
|
|
255
262
|
if (jsConfig === null || jsConfig === void 0 ? void 0 : jsConfig.useTypeScript) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/toolpack",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.16",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"@rspack/cli": "^1.4.2",
|
|
37
37
|
"@rspack/core": "^1.4.2",
|
|
38
38
|
"@rspack/plugin-html": "^0.5.8",
|
|
39
|
-
"@shuvi/compiler": "2.0.0-dev.
|
|
40
|
-
"@shuvi/shared": "2.0.0-dev.
|
|
41
|
-
"@shuvi/utils": "2.0.0-dev.
|
|
39
|
+
"@shuvi/compiler": "2.0.0-dev.16",
|
|
40
|
+
"@shuvi/shared": "2.0.0-dev.16",
|
|
41
|
+
"@shuvi/utils": "2.0.0-dev.16",
|
|
42
42
|
"@swc/helpers": "0.4.3",
|
|
43
43
|
"babel-loader": "8.2.2",
|
|
44
44
|
"babel-plugin-syntax-jsx": "6.18.0",
|