@meteorjs/rspack 0.0.5 → 0.0.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rspack.config.js +19 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
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
@@ -3,6 +3,7 @@ import fs from 'fs';
3
3
  import { createRequire } from 'module';
4
4
  import path from 'path';
5
5
  import { merge } from 'webpack-merge';
6
+ import { inspect } from "node:util";
6
7
 
7
8
  import { RequireExternalsPlugin } from './plugins/RequireExtenalsPlugin.js';
8
9
  import { getMeteorAppSwcConfig } from "./lib/swc.js";
@@ -143,7 +144,7 @@ export default function (inMeteor = {}, argv = {}) {
143
144
  const serverOutputDir = path.resolve(process.cwd(), 'server');
144
145
 
145
146
  // Determine context for bundles and assets
146
- const buildContext = Meteor.buildContext || '_rspack';
147
+ const buildContext = Meteor.buildContext || '_build';
147
148
  const bundlesContext = Meteor.bundlesContext || 'bundles';
148
149
  const assetsContext = Meteor.assetsContext || 'assets';
149
150
 
@@ -160,7 +161,7 @@ export default function (inMeteor = {}, argv = {}) {
160
161
  });
161
162
  const externals = [
162
163
  /^meteor.*/,
163
- ...(isReactEnabled ? [/^react$/, /^react-dom$/] : [])
164
+ ...(isReactEnabled ? [/^react$/, /^react-dom$/] : []),
164
165
  ];
165
166
  const alias = {
166
167
  '/': path.resolve(process.cwd()),
@@ -182,16 +183,18 @@ export default function (inMeteor = {}, argv = {}) {
182
183
  : []),
183
184
  ];
184
185
 
186
+ const reactRefreshModule = isReactEnabled ? safeRequire('@rspack/plugin-react-refresh') : null;
187
+
185
188
  // Base client config
186
189
  let clientConfig = {
187
- name: 'meteor-client',
190
+ name: '[client-rspack]',
188
191
  target: 'web',
189
192
  mode,
190
193
  entry: path.resolve(process.cwd(), buildContext, entryPath),
191
194
  output: {
192
195
  path: clientOutputDir,
193
196
  filename: () =>
194
- isDev ? outputFilename : `../${buildContext}/${outputPath}`,
197
+ isRun && !isTest ? outputFilename : `../${buildContext}/${outputPath}`,
195
198
  libraryTarget: 'commonjs',
196
199
  publicPath: '/',
197
200
  chunkFilename: `${bundlesContext}/[id].[chunkhash].js`,
@@ -220,8 +223,8 @@ export default function (inMeteor = {}, argv = {}) {
220
223
  plugins: [
221
224
  ...(isRun
222
225
  ? [
223
- ...(isReactEnabled
224
- ? [new (safeRequire('@rspack/plugin-react-refresh'))()]
226
+ ...(isReactEnabled && reactRefreshModule
227
+ ? [new reactRefreshModule()]
225
228
  : []),
226
229
  new RequireExternalsPlugin({
227
230
  filePath: path.join(buildContext, runPath),
@@ -253,8 +256,8 @@ export default function (inMeteor = {}, argv = {}) {
253
256
  }),
254
257
  ],
255
258
  watchOptions,
256
- devtool: isDev ? 'source-map' : 'hidden-source-map',
257
- ...(isRun && {
259
+ devtool: isDev || isTest ? 'source-map' : 'hidden-source-map',
260
+ ...(isRun && !isTest && {
258
261
  devServer: {
259
262
  static: { directory: clientOutputDir, publicPath: '/__rspack__/' },
260
263
  hot: true,
@@ -270,7 +273,7 @@ export default function (inMeteor = {}, argv = {}) {
270
273
 
271
274
  // Base server config
272
275
  let serverConfig = {
273
- name: 'meteor-server',
276
+ name: '[server-rspack]',
274
277
  target: 'node',
275
278
  mode,
276
279
  entry: path.resolve(process.cwd(), buildContext, entryPath),
@@ -307,7 +310,7 @@ export default function (inMeteor = {}, argv = {}) {
307
310
  ],
308
311
  watchOptions,
309
312
  devtool: isRun ? 'source-map' : 'hidden-source-map',
310
- ...(isRun &&
313
+ ...((isRun || isTest) &&
311
314
  createCacheStrategy(mode)
312
315
  ),
313
316
  };
@@ -334,10 +337,11 @@ export default function (inMeteor = {}, argv = {}) {
334
337
  }
335
338
  }
336
339
 
337
- // Return the appropriate configuration
338
- if (isClient) {
339
- return [clientConfig];
340
+ const config = isClient ? clientConfig : serverConfig;
341
+
342
+ if (Meteor.isDebug) {
343
+ console.log('Config:', inspect(config, { depth: null, colors: true }));
340
344
  }
341
- // Meteor.isServer
342
- return [serverConfig];
345
+
346
+ return [config];
343
347
  }