@meteorjs/rspack 0.0.3 → 0.0.5
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 +37 -7
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meteorjs/rspack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
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
|
@@ -71,6 +71,22 @@ function createSwcConfig({ isRun, isTypescriptEnabled, isJsxEnabled, isTsxEnable
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// Coffeescript rule
|
|
75
|
+
function createCoffeescriptConfig({ swcConfig }) {
|
|
76
|
+
return {
|
|
77
|
+
test: /\.coffee$/,
|
|
78
|
+
use: [
|
|
79
|
+
{
|
|
80
|
+
loader: 'swc-loader',
|
|
81
|
+
options: swcConfig,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
loader: 'coffee-loader',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
74
90
|
// Watch options shared across both builds
|
|
75
91
|
const watchOptions = {
|
|
76
92
|
ignored: ['**/.meteor/local/**', '**/dist/**'],
|
|
@@ -102,8 +118,12 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
102
118
|
const mode = isProd ? 'production' : 'development';
|
|
103
119
|
|
|
104
120
|
const isTypescriptEnabled = Meteor.isTypescriptEnabled || false;
|
|
105
|
-
const isJsxEnabled =
|
|
106
|
-
|
|
121
|
+
const isJsxEnabled =
|
|
122
|
+
Meteor.isJsxEnabled || (!isTypescriptEnabled && isReactEnabled) || false;
|
|
123
|
+
const isTsxEnabled =
|
|
124
|
+
Meteor.isTsxEnabled || (isTypescriptEnabled && isReactEnabled) || false;
|
|
125
|
+
|
|
126
|
+
const isCoffeescriptEnabled = Meteor.isCoffeescriptEnabled || false;
|
|
107
127
|
|
|
108
128
|
// Determine entry points
|
|
109
129
|
const entryPath = Meteor.entryPath;
|
|
@@ -132,18 +152,21 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
132
152
|
console.log('[i] Meteor flags:', Meteor);
|
|
133
153
|
}
|
|
134
154
|
|
|
135
|
-
const
|
|
155
|
+
const swcConfigRule = createSwcConfig({
|
|
136
156
|
isRun,
|
|
137
157
|
isTypescriptEnabled,
|
|
138
158
|
isJsxEnabled,
|
|
139
159
|
isTsxEnabled,
|
|
140
160
|
});
|
|
141
|
-
console.log("--> (rspack.config.js-Line: 141)\n swcConfig: ", swcConfig?.options?.jsc);
|
|
142
161
|
const externals = [
|
|
143
162
|
/^meteor.*/,
|
|
144
163
|
...(isReactEnabled ? [/^react$/, /^react-dom$/] : [])
|
|
145
164
|
];
|
|
165
|
+
const alias = {
|
|
166
|
+
'/': path.resolve(process.cwd()),
|
|
167
|
+
};
|
|
146
168
|
const extensions = [
|
|
169
|
+
...(isCoffeescriptEnabled ? ['.coffee'] : []),
|
|
147
170
|
'.ts',
|
|
148
171
|
'.tsx',
|
|
149
172
|
'.js',
|
|
@@ -153,6 +176,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
153
176
|
'.json',
|
|
154
177
|
'.wasm',
|
|
155
178
|
];
|
|
179
|
+
const extraRules = [
|
|
180
|
+
...(isCoffeescriptEnabled
|
|
181
|
+
? [createCoffeescriptConfig({ swcConfig: swcConfigRule?.options })]
|
|
182
|
+
: []),
|
|
183
|
+
];
|
|
156
184
|
|
|
157
185
|
// Base client config
|
|
158
186
|
let clientConfig = {
|
|
@@ -175,7 +203,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
175
203
|
},
|
|
176
204
|
module: {
|
|
177
205
|
rules: [
|
|
178
|
-
|
|
206
|
+
swcConfigRule,
|
|
179
207
|
...(Meteor.isBlazeEnabled
|
|
180
208
|
? [
|
|
181
209
|
{
|
|
@@ -184,9 +212,10 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
184
212
|
},
|
|
185
213
|
]
|
|
186
214
|
: []),
|
|
215
|
+
...extraRules,
|
|
187
216
|
],
|
|
188
217
|
},
|
|
189
|
-
resolve: { extensions },
|
|
218
|
+
resolve: { extensions, alias },
|
|
190
219
|
externals,
|
|
191
220
|
plugins: [
|
|
192
221
|
...(isRun
|
|
@@ -254,10 +283,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
254
283
|
},
|
|
255
284
|
optimization: { usedExports: true },
|
|
256
285
|
module: {
|
|
257
|
-
rules: [
|
|
286
|
+
rules: [swcConfigRule, ...extraRules],
|
|
258
287
|
},
|
|
259
288
|
resolve: {
|
|
260
289
|
extensions,
|
|
290
|
+
alias,
|
|
261
291
|
modules: ['node_modules', path.resolve(process.cwd())],
|
|
262
292
|
conditionNames: ['import', 'require', 'node', 'default'],
|
|
263
293
|
},
|