@meteorjs/rspack 0.1.0 → 0.1.1

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/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  defineConfig as _rspackDefineConfig,
6
6
  Configuration as _RspackConfig,
7
7
  } from '@rspack/cli';
8
- import { HtmlRspackPluginOptions, RuleSetConditions } from '@rspack/core';
8
+ import { HtmlRspackPluginOptions, RuleSetConditions, SwcLoaderOptions } from '@rspack/core';
9
9
 
10
10
  export interface MeteorRspackConfig extends _RspackConfig {
11
11
  meteor?: {
@@ -56,6 +56,11 @@ type MeteorEnv = Record<string, any> & {
56
56
  * @returns A config object with optimization configuration
57
57
  */
58
58
  splitVendorChunk: () => Record<string, object>;
59
+ /**
60
+ * Extend Rspack SWC loader config.
61
+ * @returns A config object with SWC loader config
62
+ */
63
+ extendSwcConfig: (swcConfig: SwcLoaderOptions) => Record<string, object>;
59
64
  }
60
65
 
61
66
  export type ConfigFactory = (
@@ -139,10 +139,32 @@ function splitVendorChunk() {
139
139
  });
140
140
  }
141
141
 
142
+ /**
143
+ * Extend SWC loader config
144
+ * Usage: extendSwcConfig()
145
+ *
146
+ * @returns {Record<string, object>} `{ meteorRspackConfigX: { optimization: { ... } } }`
147
+ */
148
+ function extendSwcConfig(swcConfig) {
149
+ return prepareMeteorRspackConfig({
150
+ module: {
151
+ rules: [
152
+ {
153
+ test: /\.(?:[mc]?js|jsx|[mc]?ts|tsx)$/i,
154
+ exclude: /node_modules|\.meteor\/local/,
155
+ loader: 'builtin:swc-loader',
156
+ options: swcConfig,
157
+ },
158
+ ],
159
+ },
160
+ });
161
+ }
162
+
142
163
  module.exports = {
143
164
  compileWithMeteor,
144
165
  compileWithRspack,
145
166
  setCache,
146
167
  splitVendorChunk,
168
+ extendSwcConfig,
147
169
  makeWebNodeBuiltinsAlias,
148
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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
@@ -17,6 +17,7 @@ const {
17
17
  compileWithRspack,
18
18
  setCache,
19
19
  splitVendorChunk,
20
+ extendSwcConfig,
20
21
  makeWebNodeBuiltinsAlias,
21
22
  } = require('./lib/meteorRspackHelpers.js');
22
23
 
@@ -280,6 +281,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
280
281
  enabled === 'memory' ? undefined : cacheStrategy
281
282
  );
282
283
  Meteor.splitVendorChunk = () => splitVendorChunk();
284
+ Meteor.extendSwcConfig = (customSwcConfig) => extendSwcConfig(customSwcConfig);
283
285
 
284
286
  // Add HtmlRspackPlugin function to Meteor
285
287
  Meteor.HtmlRspackPlugin = (options = {}) => {