@meteorjs/rspack 0.0.33 → 0.0.34

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.33",
3
+ "version": "0.0.34",
4
4
  "description": "Configuration logic for using Rspack in Meteor projects",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/rspack.config.js CHANGED
@@ -7,7 +7,6 @@ import { merge } from 'webpack-merge';
7
7
 
8
8
  import { cleanOmittedPaths, mergeSplitOverlap } from "./lib/mergeRulesSplitOverlap.js";
9
9
  import { getMeteorAppSwcConfig } from './lib/swc.js';
10
- import CleanBuildAssetsPlugin from './plugins/CleanBuildAssetsPlugin.js';
11
10
  import HtmlRspackPlugin from './plugins/HtmlRspackPlugin.js';
12
11
  import { RequireExternalsPlugin } from './plugins/RequireExtenalsPlugin.js';
13
12
 
@@ -87,9 +86,9 @@ function createSwcConfig({
87
86
  function keepOutsideBuild() {
88
87
  return (p) => {
89
88
  const normalized = '/' + path.normalize(p).replaceAll(path.sep, '/').replace(/^\/+/, '');
90
- const isInBuildRoot = /\/_build(\/|$)/.test(normalized);
91
- const isInBuildStar = /\/_build-[^/]+(\/|$)/.test(normalized);
92
- return !(isInBuildRoot || isInBuildStar); // true => KEEP, false => DELETE
89
+ const isInBuildRoot = /\/build(\/|$)/.test(normalized);
90
+ const isInBuildStar = /\/build-[^/]+(\/|$)/.test(normalized);
91
+ return !(isInBuildRoot || isInBuildStar);
93
92
  };
94
93
  }
95
94
 
@@ -100,7 +99,7 @@ const defaultWatchOptions = {
100
99
 
101
100
  /**
102
101
  * @param {{ isClient: boolean; isServer: boolean; isDevelopment?: boolean; isProduction?: boolean; isTest?: boolean }} Meteor
103
- * @param {{ mode?: string; clientEntry?: string; serverEntry?: string; clientOutputFolder?: string; serverOutputFolder?: string; bundlesContext?: string; assetsContext?: string; serverAssetsContext?: string }} argv
102
+ * @param {{ mode?: string; clientEntry?: string; serverEntry?: string; clientOutputFolder?: string; serverOutputFolder?: string; chunksContext?: string; assetsContext?: string; serverAssetsContext?: string }} argv
104
103
  * @returns {import('@rspack/cli').Configuration[]}
105
104
  */
106
105
  export default function (inMeteor = {}, argv = {}) {
@@ -156,8 +155,8 @@ export default function (inMeteor = {}, argv = {}) {
156
155
 
157
156
  // Determine context for bundles and assets
158
157
  const buildContext = Meteor.buildContext || '_build';
159
- const bundlesContext = Meteor.bundlesContext || 'bundles';
160
- const assetsContext = Meteor.assetsContext || 'assets';
158
+ const assetsContext = Meteor.assetsContext || 'build-assets';
159
+ const chunksContext = Meteor.chunksContext || 'build-chunks';
161
160
 
162
161
  // Determine build output and pass to Meteor
163
162
  const buildOutputDir = path.resolve(process.cwd(), buildContext, outputDir);
@@ -267,12 +266,12 @@ export default function (inMeteor = {}, argv = {}) {
267
266
  isDevEnvironment ? outputFilename : `../${buildContext}/${outputPath}`,
268
267
  libraryTarget: 'commonjs',
269
268
  publicPath: '/',
270
- chunkFilename: `${bundlesContext}/[id]${isProd ? '.[chunkhash]' : ''}.js`,
269
+ chunkFilename: `${chunksContext}/[id]${isProd ? '.[chunkhash]' : ''}.js`,
271
270
  assetModuleFilename: `${assetsContext}/[hash][ext][query]`,
272
- cssFilename: `${assetsContext}/[name]${
271
+ cssFilename: `${chunksContext}/[name]${
273
272
  isProd ? '.[contenthash]' : ''
274
273
  }.css`,
275
- cssChunkFilename: `${assetsContext}/[id]${
274
+ cssChunkFilename: `${chunksContext}/[id]${
276
275
  isProd ? '.[contenthash]' : ''
277
276
  }.css`,
278
277
  ...(isProd && { clean: { keep: keepOutsideBuild() } }),
@@ -298,13 +297,6 @@ export default function (inMeteor = {}, argv = {}) {
298
297
  resolve: { extensions, alias },
299
298
  externals,
300
299
  plugins: [
301
- ...(isProd
302
- ? [
303
- new CleanBuildAssetsPlugin({
304
- verbose: Meteor.isDebug || Meteor.isVerbose,
305
- }),
306
- ]
307
- : []),
308
300
  ...[
309
301
  ...(isReactEnabled && reactRefreshModule && isDevEnvironment
310
302
  ? [new reactRefreshModule()]
@@ -362,7 +354,7 @@ export default function (inMeteor = {}, argv = {}) {
362
354
  path: serverOutputDir,
363
355
  filename: () => `../${buildContext}/${outputPath}`,
364
356
  libraryTarget: 'commonjs',
365
- chunkFilename: `${bundlesContext}/[id]${isProd ? '.[chunkhash]' : ''}.js`,
357
+ chunkFilename: `${chunksContext}/[id]${isProd ? '.[chunkhash]' : ''}.js`,
366
358
  assetModuleFilename: `${assetsContext}/[hash][ext][query]`,
367
359
  ...(isProd && { clean: { keep: keepOutsideBuild() } }),
368
360
  },
@@ -1,52 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
-
4
- /**
5
- * Rspack plugin to clean and recreate build directories
6
- * before each compilation.
7
- *
8
- * Options:
9
- * - targets {string[]} : Directories to clean.
10
- * Defaults:
11
- * - public/_build-assets
12
- * - public/_build-bundles
13
- * - private/_build-assets
14
- * - verbose {boolean} : If true, logs cleaning operations. Default: false
15
- */
16
- export default class CleanBuildAssetsPlugin {
17
- constructor(options = {}) {
18
- const defaults = [
19
- 'public/_build-assets',
20
- 'private/_build-assets',
21
- ];
22
-
23
- this.targets = Array.isArray(options.targets)
24
- ? options.targets
25
- : defaults;
26
-
27
- this.verbose = options.verbose || false;
28
- }
29
-
30
- apply(compiler) {
31
- compiler.hooks.beforeRun.tapPromise(
32
- 'CleanBuildAssetsPlugin',
33
- async () => {
34
- for (const target of this.targets) {
35
- const dir = path.resolve(compiler.context, target);
36
- try {
37
- await fs.rm(dir, { recursive: true, force: true });
38
- await fs.mkdir(dir, { recursive: true });
39
- if (this.verbose) {
40
- console.log(`[CleanBuildAssetsPlugin] Cleaned: ${dir}`);
41
- }
42
- } catch (err) {
43
- console.warn(
44
- `[CleanBuildAssetsPlugin] Failed to clean ${dir}:`,
45
- err.message
46
- );
47
- }
48
- }
49
- }
50
- )
51
- }
52
- }