@meteorjs/rspack 0.0.4 → 0.0.6
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 +1 -2
- package/rspack.config.js +48 -13
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meteorjs/rspack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Configuration logic for using Rspack in Meteor projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@rspack/plugin-react-refresh": "^1.4.3",
|
|
11
10
|
"ignore-loader": "^0.1.2",
|
|
12
11
|
"webpack-merge": "^6.0.1"
|
|
13
12
|
},
|
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";
|
|
@@ -71,6 +72,22 @@ function createSwcConfig({ isRun, isTypescriptEnabled, isJsxEnabled, isTsxEnable
|
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
// Coffeescript rule
|
|
76
|
+
function createCoffeescriptConfig({ swcConfig }) {
|
|
77
|
+
return {
|
|
78
|
+
test: /\.coffee$/,
|
|
79
|
+
use: [
|
|
80
|
+
{
|
|
81
|
+
loader: 'swc-loader',
|
|
82
|
+
options: swcConfig,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
loader: 'coffee-loader',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
74
91
|
// Watch options shared across both builds
|
|
75
92
|
const watchOptions = {
|
|
76
93
|
ignored: ['**/.meteor/local/**', '**/dist/**'],
|
|
@@ -102,8 +119,12 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
102
119
|
const mode = isProd ? 'production' : 'development';
|
|
103
120
|
|
|
104
121
|
const isTypescriptEnabled = Meteor.isTypescriptEnabled || false;
|
|
105
|
-
const isJsxEnabled =
|
|
106
|
-
|
|
122
|
+
const isJsxEnabled =
|
|
123
|
+
Meteor.isJsxEnabled || (!isTypescriptEnabled && isReactEnabled) || false;
|
|
124
|
+
const isTsxEnabled =
|
|
125
|
+
Meteor.isTsxEnabled || (isTypescriptEnabled && isReactEnabled) || false;
|
|
126
|
+
|
|
127
|
+
const isCoffeescriptEnabled = Meteor.isCoffeescriptEnabled || false;
|
|
107
128
|
|
|
108
129
|
// Determine entry points
|
|
109
130
|
const entryPath = Meteor.entryPath;
|
|
@@ -132,7 +153,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
132
153
|
console.log('[i] Meteor flags:', Meteor);
|
|
133
154
|
}
|
|
134
155
|
|
|
135
|
-
const
|
|
156
|
+
const swcConfigRule = createSwcConfig({
|
|
136
157
|
isRun,
|
|
137
158
|
isTypescriptEnabled,
|
|
138
159
|
isJsxEnabled,
|
|
@@ -142,7 +163,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
142
163
|
/^meteor.*/,
|
|
143
164
|
...(isReactEnabled ? [/^react$/, /^react-dom$/] : [])
|
|
144
165
|
];
|
|
166
|
+
const alias = {
|
|
167
|
+
'/': path.resolve(process.cwd()),
|
|
168
|
+
};
|
|
145
169
|
const extensions = [
|
|
170
|
+
...(isCoffeescriptEnabled ? ['.coffee'] : []),
|
|
146
171
|
'.ts',
|
|
147
172
|
'.tsx',
|
|
148
173
|
'.js',
|
|
@@ -152,6 +177,13 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
152
177
|
'.json',
|
|
153
178
|
'.wasm',
|
|
154
179
|
];
|
|
180
|
+
const extraRules = [
|
|
181
|
+
...(isCoffeescriptEnabled
|
|
182
|
+
? [createCoffeescriptConfig({ swcConfig: swcConfigRule?.options })]
|
|
183
|
+
: []),
|
|
184
|
+
];
|
|
185
|
+
|
|
186
|
+
const reactRefreshModule = isReactEnabled ? safeRequire('@rspack/plugin-react-refresh') : null;
|
|
155
187
|
|
|
156
188
|
// Base client config
|
|
157
189
|
let clientConfig = {
|
|
@@ -174,7 +206,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
174
206
|
},
|
|
175
207
|
module: {
|
|
176
208
|
rules: [
|
|
177
|
-
|
|
209
|
+
swcConfigRule,
|
|
178
210
|
...(Meteor.isBlazeEnabled
|
|
179
211
|
? [
|
|
180
212
|
{
|
|
@@ -183,15 +215,16 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
183
215
|
},
|
|
184
216
|
]
|
|
185
217
|
: []),
|
|
218
|
+
...extraRules,
|
|
186
219
|
],
|
|
187
220
|
},
|
|
188
|
-
resolve: { extensions },
|
|
221
|
+
resolve: { extensions, alias },
|
|
189
222
|
externals,
|
|
190
223
|
plugins: [
|
|
191
224
|
...(isRun
|
|
192
225
|
? [
|
|
193
|
-
...(isReactEnabled
|
|
194
|
-
? [new (
|
|
226
|
+
...(isReactEnabled && reactRefreshModule
|
|
227
|
+
? [new reactRefreshModule()]
|
|
195
228
|
: []),
|
|
196
229
|
new RequireExternalsPlugin({
|
|
197
230
|
filePath: path.join(buildContext, runPath),
|
|
@@ -253,10 +286,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
253
286
|
},
|
|
254
287
|
optimization: { usedExports: true },
|
|
255
288
|
module: {
|
|
256
|
-
rules: [
|
|
289
|
+
rules: [swcConfigRule, ...extraRules],
|
|
257
290
|
},
|
|
258
291
|
resolve: {
|
|
259
292
|
extensions,
|
|
293
|
+
alias,
|
|
260
294
|
modules: ['node_modules', path.resolve(process.cwd())],
|
|
261
295
|
conditionNames: ['import', 'require', 'node', 'default'],
|
|
262
296
|
},
|
|
@@ -303,10 +337,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
303
337
|
}
|
|
304
338
|
}
|
|
305
339
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
340
|
+
const config = isClient ? clientConfig : serverConfig;
|
|
341
|
+
|
|
342
|
+
if (Meteor.isDebug) {
|
|
343
|
+
console.log('Config:', inspect(config, { depth: null, colors: true }));
|
|
309
344
|
}
|
|
310
|
-
|
|
311
|
-
return [
|
|
345
|
+
|
|
346
|
+
return [config];
|
|
312
347
|
}
|