@meteorjs/rspack 0.0.4 → 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 -6
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,7 +152,7 @@ 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,
|
|
@@ -142,7 +162,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
142
162
|
/^meteor.*/,
|
|
143
163
|
...(isReactEnabled ? [/^react$/, /^react-dom$/] : [])
|
|
144
164
|
];
|
|
165
|
+
const alias = {
|
|
166
|
+
'/': path.resolve(process.cwd()),
|
|
167
|
+
};
|
|
145
168
|
const extensions = [
|
|
169
|
+
...(isCoffeescriptEnabled ? ['.coffee'] : []),
|
|
146
170
|
'.ts',
|
|
147
171
|
'.tsx',
|
|
148
172
|
'.js',
|
|
@@ -152,6 +176,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
152
176
|
'.json',
|
|
153
177
|
'.wasm',
|
|
154
178
|
];
|
|
179
|
+
const extraRules = [
|
|
180
|
+
...(isCoffeescriptEnabled
|
|
181
|
+
? [createCoffeescriptConfig({ swcConfig: swcConfigRule?.options })]
|
|
182
|
+
: []),
|
|
183
|
+
];
|
|
155
184
|
|
|
156
185
|
// Base client config
|
|
157
186
|
let clientConfig = {
|
|
@@ -174,7 +203,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
174
203
|
},
|
|
175
204
|
module: {
|
|
176
205
|
rules: [
|
|
177
|
-
|
|
206
|
+
swcConfigRule,
|
|
178
207
|
...(Meteor.isBlazeEnabled
|
|
179
208
|
? [
|
|
180
209
|
{
|
|
@@ -183,9 +212,10 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
183
212
|
},
|
|
184
213
|
]
|
|
185
214
|
: []),
|
|
215
|
+
...extraRules,
|
|
186
216
|
],
|
|
187
217
|
},
|
|
188
|
-
resolve: { extensions },
|
|
218
|
+
resolve: { extensions, alias },
|
|
189
219
|
externals,
|
|
190
220
|
plugins: [
|
|
191
221
|
...(isRun
|
|
@@ -253,10 +283,11 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
253
283
|
},
|
|
254
284
|
optimization: { usedExports: true },
|
|
255
285
|
module: {
|
|
256
|
-
rules: [
|
|
286
|
+
rules: [swcConfigRule, ...extraRules],
|
|
257
287
|
},
|
|
258
288
|
resolve: {
|
|
259
289
|
extensions,
|
|
290
|
+
alias,
|
|
260
291
|
modules: ['node_modules', path.resolve(process.cwd())],
|
|
261
292
|
conditionNames: ['import', 'require', 'node', 'default'],
|
|
262
293
|
},
|