@meteorjs/rspack 0.0.28 → 0.0.30

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "Configuration logic for using Rspack in Meteor projects",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,7 +28,7 @@ export default class CleanBuildAssetsPlugin {
28
28
  }
29
29
 
30
30
  apply(compiler) {
31
- compiler.hooks.beforeCompile.tapPromise(
31
+ compiler.hooks.beforeRun.tapPromise(
32
32
  'CleanBuildAssetsPlugin',
33
33
  async () => {
34
34
  for (const target of this.targets) {
package/rspack.config.js CHANGED
@@ -98,6 +98,16 @@ function createCoffeescriptConfig({ swcConfig }) {
98
98
  };
99
99
  }
100
100
 
101
+ // Keep files outside of build folders
102
+ function keepOutsideBuild() {
103
+ return (p) => {
104
+ const normalized = '/' + path.normalize(p).replaceAll(path.sep, '/').replace(/^\/+/, '');
105
+ const isInBuildRoot = /\/_build(\/|$)/.test(normalized);
106
+ const isInBuildStar = /\/_build-[^/]+(\/|$)/.test(normalized);
107
+ return !(isInBuildRoot || isInBuildStar); // true => KEEP, false => DELETE
108
+ };
109
+ }
110
+
101
111
  // Watch options shared across both builds
102
112
  const defaultWatchOptions = {
103
113
  ignored: ['**/.meteor/local/**', '**/dist/**'],
@@ -282,7 +292,7 @@ export default function (inMeteor = {}, argv = {}) {
282
292
  cssChunkFilename: `${assetsContext}/[id]${
283
293
  isProd ? '.[contenthash]' : ''
284
294
  }.css`,
285
- clean: isProd,
295
+ ...(isProd && { clean: { keep: keepOutsideBuild() } }),
286
296
  },
287
297
  optimization: {
288
298
  usedExports: true,
@@ -371,7 +381,7 @@ export default function (inMeteor = {}, argv = {}) {
371
381
  libraryTarget: 'commonjs',
372
382
  chunkFilename: `${bundlesContext}/[id]${isProd ? '.[chunkhash]' : ''}.js`,
373
383
  assetModuleFilename: `${assetsContext}/[hash][ext][query]`,
374
- clean: isProd,
384
+ ...(isProd && { clean: { keep: keepOutsideBuild() } }),
375
385
  },
376
386
  optimization: { usedExports: true },
377
387
  module: {