@meteorjs/rspack 0.0.63 → 0.0.65

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/lib/test.js CHANGED
@@ -8,14 +8,15 @@ const { createIgnoreRegex, createIgnoreGlobConfig } = require("./ignore.js");
8
8
  * @param {boolean} options.isAppTest - Whether this is an app test
9
9
  * @param {string} options.projectDir - The project directory
10
10
  * @param {string} options.buildContext - The build context
11
- * @param {string[]} options.entries - Array of ignore patterns
11
+ * @param {string[]} options.ignoreEntries - Array of ignore patterns
12
12
  * @returns {string} The path to the generated file
13
13
  */
14
14
  const generateEagerTestFile = ({
15
15
  isAppTest,
16
16
  projectDir,
17
17
  buildContext,
18
- entries = [],
18
+ ignoreEntries: inIgnoreEntries = [],
19
+ prefix: inPrefix = '',
19
20
  }) => {
20
21
  const distDir = path.resolve(projectDir, ".meteor/local/test");
21
22
  if (!fs.existsSync(distDir)) {
@@ -29,7 +30,7 @@ const generateEagerTestFile = ({
29
30
  "**/public/**",
30
31
  "**/private/**",
31
32
  `**/${buildContext}/**`,
32
- ...entries,
33
+ ...inIgnoreEntries,
33
34
  ];
34
35
 
35
36
  // Create regex from ignore entries
@@ -37,7 +38,10 @@ const generateEagerTestFile = ({
37
38
  createIgnoreGlobConfig(ignoreEntries)
38
39
  );
39
40
 
40
- const filename = isAppTest ? "eager-app-tests.mjs" : "eager-tests.mjs";
41
+ const prefix = inPrefix && `${inPrefix}-` || '';
42
+ const filename = isAppTest
43
+ ? `${prefix}eager-app-tests.mjs`
44
+ : `${prefix}eager-tests.mjs`;
41
45
  const filePath = path.resolve(distDir, filename);
42
46
  const regExp = isAppTest
43
47
  ? "/\\.app-(?:test|spec)s?\\.[^.]+$/"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "Configuration logic for using Rspack in Meteor projects",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/rspack.config.js CHANGED
@@ -136,7 +136,7 @@ function createSwcConfig({
136
136
  return {
137
137
  test: /\.(?:[mc]?js|jsx|[mc]?ts|tsx)$/i,
138
138
  exclude: /node_modules|\.meteor\/local/,
139
- loader: 'builtin:swc-loader',
139
+ loader: "builtin:swc-loader",
140
140
  options: swcConfig,
141
141
  };
142
142
  }
@@ -217,6 +217,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
217
217
  const isTestModule = !!Meteor.isTestModule;
218
218
  const isTestEager = !!Meteor.isTestEager;
219
219
  const isTestFullApp = !!Meteor.isTestFullApp;
220
+ const isTestLike = !!Meteor.isTestLike;
220
221
  const swcExternalHelpers = !!Meteor.swcExternalHelpers;
221
222
  const isNative = !!Meteor.isNative;
222
223
  const mode = isProd ? 'production' : 'development';
@@ -278,7 +279,6 @@ module.exports = async function (inMeteor = {}, argv = {}) {
278
279
  enabled === 'memory' ? undefined : cacheStrategy
279
280
  );
280
281
  Meteor.splitVendorChunk = () => splitVendorChunk();
281
- Meteor.createAngularConfig = () => createAngularConfig();
282
282
 
283
283
  // Add HtmlRspackPlugin function to Meteor
284
284
  Meteor.HtmlRspackPlugin = (options = {}) => {
@@ -406,15 +406,33 @@ module.exports = async function (inMeteor = {}, argv = {}) {
406
406
  ]
407
407
  : [];
408
408
 
409
- const clientNameConfig = `[${(isTest && 'test-') || ''}${
410
- (isTestModule && 'module') || 'client'
411
- }-rspack]`;
409
+
410
+ const clientEntry =
411
+ isTest && isTestEager && isTestFullApp
412
+ ? generateEagerTestFile({
413
+ isAppTest: true,
414
+ projectDir,
415
+ buildContext,
416
+ ignoreEntries: [...meteorIgnoreEntries, '**/server/**'],
417
+ prefix: 'client',
418
+ })
419
+ : isTest && isTestEager
420
+ ? generateEagerTestFile({
421
+ isAppTest: false,
422
+ isClient: true,
423
+ projectDir,
424
+ buildContext,
425
+ ignoreEntries: [...meteorIgnoreEntries, '**/server/**'],
426
+ prefix: 'client',
427
+ })
428
+ : path.resolve(process.cwd(), buildContext, entryPath);
429
+ const clientNameConfig = `[${(isTest && 'test-') || ''}client-rspack]`;
412
430
  // Base client config
413
431
  let clientConfig = {
414
432
  name: clientNameConfig,
415
433
  target: 'web',
416
434
  mode,
417
- entry: path.resolve(process.cwd(), buildContext, entryPath),
435
+ entry: clientEntry,
418
436
  output: {
419
437
  path: clientOutputDir,
420
438
  filename: (_module) => {
@@ -459,6 +477,15 @@ module.exports = async function (inMeteor = {}, argv = {}) {
459
477
  : []),
460
478
  ...extraRules,
461
479
  ],
480
+ ...(Meteor.isTest && {
481
+ parser: {
482
+ javascript: {
483
+ dynamicImportMode: 'eager',
484
+ dynamicImportPrefetch: true,
485
+ dynamicImportPreload: true
486
+ },
487
+ },
488
+ }),
462
489
  },
463
490
  resolve: { extensions, alias, fallback },
464
491
  externals,
@@ -472,8 +499,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
472
499
  new DefinePlugin({
473
500
  'Meteor.isClient': JSON.stringify(true),
474
501
  'Meteor.isServer': JSON.stringify(false),
475
- 'Meteor.isTest': JSON.stringify(isTest && !isTestFullApp),
476
- 'Meteor.isAppTest': JSON.stringify(isTest && isTestFullApp),
502
+ 'Meteor.isTest': JSON.stringify(isTestLike && !isTestFullApp),
503
+ 'Meteor.isAppTest': JSON.stringify(isTestLike && isTestFullApp),
477
504
  'Meteor.isDevelopment': JSON.stringify(isDev),
478
505
  'Meteor.isProduction': JSON.stringify(isProd),
479
506
  }),
@@ -503,26 +530,25 @@ module.exports = async function (inMeteor = {}, argv = {}) {
503
530
  ...merge(cacheStrategy, { experiments: { css: true } })
504
531
  };
505
532
 
506
-
507
533
  const serverEntry =
508
534
  isTest && isTestEager && isTestFullApp
509
535
  ? generateEagerTestFile({
510
536
  isAppTest: true,
511
537
  projectDir,
512
538
  buildContext,
513
- entries: meteorIgnoreEntries,
539
+ ignoreEntries: [...meteorIgnoreEntries, '**/client/**'],
540
+ prefix: 'server',
514
541
  })
515
542
  : isTest && isTestEager
516
543
  ? generateEagerTestFile({
517
544
  isAppTest: false,
518
545
  projectDir,
519
546
  buildContext,
520
- entries: meteorIgnoreEntries,
547
+ ignoreEntries: [...meteorIgnoreEntries, '**/client/**'],
548
+ prefix: 'server',
521
549
  })
522
550
  : path.resolve(projectDir, buildContext, entryPath);
523
- const serverNameConfig = `[${(isTest && 'test-') || ''}${
524
- (isTestModule && 'module') || 'server'
525
- }-rspack]`;
551
+ const serverNameConfig = `[${(isTest && 'test-') || ''}server-rspack]`;
526
552
  // Base server config
527
553
  let serverConfig = {
528
554
  name: serverNameConfig,
@@ -570,8 +596,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
570
596
  : {
571
597
  'Meteor.isClient': JSON.stringify(false),
572
598
  'Meteor.isServer': JSON.stringify(true),
573
- 'Meteor.isTest': JSON.stringify(isTest && !isTestFullApp),
574
- 'Meteor.isAppTest': JSON.stringify(isTest && isTestFullApp),
599
+ 'Meteor.isTest': JSON.stringify(isTestLike && !isTestFullApp),
600
+ 'Meteor.isAppTest': JSON.stringify(isTestLike && isTestFullApp),
575
601
  'Meteor.isDevelopment': JSON.stringify(isDev),
576
602
  'Meteor.isProduction': JSON.stringify(isProd),
577
603
  },