frosty 0.0.150 → 0.0.151

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/README.md CHANGED
@@ -117,6 +117,16 @@ module.exports = {
117
117
  basepath: '/', // (Optional) URL base path for this entry
118
118
  }
119
119
  },
120
+ workers: { // (Optional) Worker entry points
121
+ myClientWorker: {
122
+ entry: 'src/workers/myClientWorker.js', // Path to worker entry file
123
+ client: true, // true = browser worker (bundled into public/workers/)
124
+ },
125
+ myServerWorker: {
126
+ entry: 'src/workers/myServerWorker.js', // Path to worker entry file
127
+ client: false, // false = server worker (bundled into workers/)
128
+ }
129
+ },
120
130
  moduleSuffixes: { // (Optional) Custom module resolution suffixes
121
131
  client: ['.browser', '.web', ''],
122
132
  server: ['.node', '.server', '.web', '']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frosty",
3
- "version": "0.0.150",
3
+ "version": "0.0.151",
4
4
  "main": "dist/index",
5
5
  "module": "dist/index",
6
6
  "types": "dist/index",
@@ -214,6 +214,16 @@ export default async (env, argv) => {
214
214
  server: config.moduleSuffixes?.server ?? ['.node', '.server', '.web', ''],
215
215
  };
216
216
 
217
+ const clientWorkers = [];
218
+ const serverWorkers = [];
219
+ for (const [name, { entry, client }] of _.entries(config.workers || {})) {
220
+ if (client) {
221
+ clientWorkers.push({ name, entry });
222
+ } else {
223
+ serverWorkers.push({ name, entry });
224
+ }
225
+ }
226
+
217
227
  return [
218
228
  ..._.map(inputs, ({ entry }, name) => ({
219
229
  ...webpackConfiguration,
@@ -250,6 +260,34 @@ export default async (env, argv) => {
250
260
  ]
251
261
  }
252
262
  })),
263
+ {
264
+ ...webpackConfiguration,
265
+ optimization: webpackOptimization({ server: false }),
266
+ plugins: webpackPlugins,
267
+ entry: {
268
+ ..._.fromPairs(clientWorkers.map(({ name, entry }) => ([`workers/${name}`, [
269
+ path.resolve(__dirname, 'node_modules/core-js/stable'),
270
+ path.resolve(process.cwd(), entry),
271
+ ]]))),
272
+ },
273
+ output: {
274
+ path: path.join(OUTPUT_DIR, 'public'),
275
+ },
276
+ resolve: {
277
+ ...webpackConfiguration.resolve,
278
+ extensions: [
279
+ ...moduleSuffixes.client.flatMap(x => [`${x}.tsx`, `${x}.jsx`]),
280
+ ...moduleSuffixes.client.flatMap(x => [`${x}.ts`, `${x}.mjs`, `${x}.js`]),
281
+ '...'
282
+ ],
283
+ },
284
+ module: {
285
+ rules: [
286
+ babelLoaderConfiguration({ server: false }),
287
+ ...config.options?.module?.rules ?? [],
288
+ ]
289
+ }
290
+ },
253
291
  {
254
292
  ...webpackConfiguration,
255
293
  optimization: webpackOptimization({ server: true }),
@@ -269,6 +307,10 @@ export default async (env, argv) => {
269
307
  path.resolve(__dirname, 'node_modules/core-js/stable'),
270
308
  path.resolve(__dirname, 'src/server/index.js'),
271
309
  ],
310
+ ..._.fromPairs(serverWorkers.map(({ name, entry }) => ([`workers/${name}`, [
311
+ path.resolve(__dirname, 'node_modules/core-js/stable'),
312
+ path.resolve(process.cwd(), entry),
313
+ ]]))),
272
314
  },
273
315
  output: {
274
316
  path: OUTPUT_DIR,