@quilted/rollup 0.2.10 → 0.2.12
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/CHANGELOG.md +12 -0
- package/build/esm/app.mjs +6 -5
- package/build/esm/features/workers.mjs +11 -7
- package/build/esm/shared/browserslist.mjs +44 -35
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/features/workers.d.ts +4 -10
- package/build/typescript/features/workers.d.ts.map +1 -1
- package/build/typescript/package.d.ts +2 -2
- package/build/typescript/shared/browserslist.d.ts +1 -0
- package/build/typescript/shared/browserslist.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/app.ts +5 -3
- package/source/features/workers.ts +16 -11
- package/source/shared/browserslist.ts +60 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../source/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAmB,KAAK,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../source/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAmB,KAAK,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAG/E,OA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,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC3B;;;;;;;;;;EAyDL;AAED,wBAAgB,4BAA4B;;;;;;;;;;EAqE3C;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,KAAK,EACL,IAAoB,GACrB,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,+BAgBA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Plugin, InputOptions, OutputOptions, OutputChunk } from 'rollup';
|
|
2
|
+
export declare const PREFIX = "\0quilt-worker:";
|
|
2
3
|
export interface WorkerWrapper {
|
|
3
4
|
readonly module: string;
|
|
4
5
|
readonly function: string;
|
|
@@ -45,15 +46,8 @@ export interface Options {
|
|
|
45
46
|
inputOptions?: ValueOrUpdateGetter<InputOptions>;
|
|
46
47
|
outputOptions?: ValueOrUpdateGetter<OutputOptions>;
|
|
47
48
|
baseURL?: ValueOrGetter<string | undefined, BaseURLContext>;
|
|
49
|
+
format?: 'module' | 'classic';
|
|
48
50
|
}
|
|
49
|
-
export declare function workers({ write, baseURL, plugins, inputOptions, outputOptions, }?: Options): Plugin;
|
|
50
|
-
export declare function
|
|
51
|
-
name: string;
|
|
52
|
-
resolveId(this: import("rollup").PluginContext, source: string): {
|
|
53
|
-
id: string;
|
|
54
|
-
} | null;
|
|
55
|
-
load(this: import("rollup").PluginContext, id: string): Promise<string | null>;
|
|
56
|
-
};
|
|
57
|
-
export declare function parseWorkerImport(id: string, prefix?: string): WorkerContext | undefined;
|
|
58
|
-
export declare function serializeWorkerImport({ module, wrapper }: WorkerContext, prefix?: string): string;
|
|
51
|
+
export declare function workers({ format, write, baseURL, plugins, inputOptions, outputOptions, }?: Options): Plugin;
|
|
52
|
+
export declare function contentForWorker({ module, wrapper }: WorkerContext): string;
|
|
59
53
|
//# sourceMappingURL=workers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../../source/features/workers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,WAAW,EAEZ,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../../source/features/workers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,WAAW,EAEZ,MAAM,QAAQ,CAAC;AAIhB,eAAO,MAAM,MAAM,oBAAoB,CAAC;AAIxC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;CACjC;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,OAAO,SAAS,aAAa,GAAG,aAAa,IACtE,CAAC,GACD,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3C,MAAM,MAAM,mBAAmB,CAC7B,CAAC,EACD,OAAO,SAAS,aAAa,GAAG,aAAa,IAC3C,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,OAAO;IACtB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;IACjD,aAAa,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,SAAS,EAAE,cAAc,CAAC,CAAC;IAC5D,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC/B;AAED,wBAAgB,OAAO,CAAC,EACtB,MAAkB,EAClB,KAAa,EACb,OAAO,EACP,OAAwB,EACxB,YAAiB,EACjB,aAAkB,GACnB,GAAE,OAAY,GAAG,MAAM,CA6HvB;AAkED,wBAAgB,gBAAgB,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,EAAE,aAAa,UAUhE"}
|
|
@@ -117,7 +117,7 @@ export declare function quiltPackage({ root, commonjs, esnext: explicitESNext, e
|
|
|
117
117
|
generatedCode: "es2015";
|
|
118
118
|
};
|
|
119
119
|
} | {
|
|
120
|
-
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false |
|
|
120
|
+
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | import("rollup").NullValue | Plugin<any> | import("rollup").InputPluginOption[]> | null)[];
|
|
121
121
|
output: OutputOptions | OutputOptions[] | {
|
|
122
122
|
preserveModules: true;
|
|
123
123
|
preserveModulesRoot: string;
|
|
@@ -188,7 +188,7 @@ export declare function quiltPackageESNext({ root, react: useReact, graphql, ent
|
|
|
188
188
|
generatedCode: "es2015";
|
|
189
189
|
};
|
|
190
190
|
} | {
|
|
191
|
-
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false |
|
|
191
|
+
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | import("rollup").NullValue | Plugin<any> | import("rollup").InputPluginOption[]> | null)[];
|
|
192
192
|
output: OutputOptions | OutputOptions[] | {
|
|
193
193
|
preserveModules: true;
|
|
194
194
|
preserveModulesRoot: string;
|
|
@@ -25,4 +25,5 @@ export declare function rollupGenerateOptionsForBrowsers(browsers: readonly stri
|
|
|
25
25
|
reservedNamesAsProps: boolean;
|
|
26
26
|
symbols: boolean;
|
|
27
27
|
}>;
|
|
28
|
+
export declare function targetsSupportModuleWebWorkers(browsers: readonly string[]): Promise<boolean>;
|
|
28
29
|
//# sourceMappingURL=browserslist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserslist.d.ts","sourceRoot":"","sources":["../../../source/shared/browserslist.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GACnC,SAAS,MAAM,EAAE,GACjB;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEN,wBAAsB,4BAA4B,CAChD,eAAe,GAAE,2BAAgC,EACjD,EAAC,IAAI,EAAC,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM;;;GA0B7B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,wBAAsB,gBAAgB,CAAC,EACrC,IAAoB,GACrB,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAwB/C;AAED,wBAAsB,iCAAiC,CACrD,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAuCjC;AAID,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"browserslist.d.ts","sourceRoot":"","sources":["../../../source/shared/browserslist.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GACnC,SAAS,MAAM,EAAE,GACjB;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEN,wBAAsB,4BAA4B,CAChD,eAAe,GAAE,2BAAgC,EACjD,EAAC,IAAI,EAAC,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM;;;GA0B7B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,wBAAsB,gBAAgB,CAAC,EACrC,IAAoB,GACrB,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAwB/C;AAED,wBAAsB,iCAAiC,CACrD,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAuCjC;AAID,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,oBAYrE;AAmBD,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,SAAS,MAAM,EAAE;;;;;;;GA8C5B;AAED,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,SAAS,MAAM,EAAE,oBAe5B"}
|
package/package.json
CHANGED
package/source/app.ts
CHANGED
|
@@ -27,10 +27,11 @@ import {
|
|
|
27
27
|
} from './shared/rollup.ts';
|
|
28
28
|
import {createMagicModulePlugin} from './shared/magic-module.ts';
|
|
29
29
|
import {
|
|
30
|
-
targetsSupportModules,
|
|
31
30
|
getBrowserGroups,
|
|
32
31
|
getBrowserGroupTargetDetails,
|
|
33
32
|
getBrowserGroupRegularExpressions,
|
|
33
|
+
targetsSupportModules,
|
|
34
|
+
targetsSupportModuleWebWorkers,
|
|
34
35
|
rollupGenerateOptionsForBrowsers,
|
|
35
36
|
type BrowserGroupTargetSelection,
|
|
36
37
|
} from './shared/browserslist.ts';
|
|
@@ -355,6 +356,7 @@ export async function quiltAppBrowser({
|
|
|
355
356
|
{workers},
|
|
356
357
|
{esnext},
|
|
357
358
|
nodePlugins,
|
|
359
|
+
supportsModuleWorkers,
|
|
358
360
|
] = await Promise.all([
|
|
359
361
|
import('rollup-plugin-visualizer'),
|
|
360
362
|
import('./features/env.ts'),
|
|
@@ -369,6 +371,7 @@ export async function quiltAppBrowser({
|
|
|
369
371
|
import('./features/workers.ts'),
|
|
370
372
|
import('./features/esnext.ts'),
|
|
371
373
|
getNodePlugins({bundle: true}),
|
|
374
|
+
targetsSupportModuleWebWorkers(browserGroup.browsers),
|
|
372
375
|
]);
|
|
373
376
|
|
|
374
377
|
const plugins: InputPluginOption[] = [
|
|
@@ -419,9 +422,8 @@ export async function quiltAppBrowser({
|
|
|
419
422
|
}),
|
|
420
423
|
workers({
|
|
421
424
|
baseURL,
|
|
425
|
+
format: supportsModuleWorkers ? 'module' : 'classic',
|
|
422
426
|
outputOptions: {
|
|
423
|
-
format: 'iife',
|
|
424
|
-
inlineDynamicImports: true,
|
|
425
427
|
dir: project.resolve(`build/assets`),
|
|
426
428
|
entryFileNames: `[name]${targetFilenamePart}.[hash].js`,
|
|
427
429
|
assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
|
|
13
13
|
import {multiline} from '../shared/strings.ts';
|
|
14
14
|
|
|
15
|
-
const PREFIX = '\0quilt-worker:';
|
|
15
|
+
export const PREFIX = '\0quilt-worker:';
|
|
16
16
|
const ENTRY_PREFIX = '\0quilt-worker-entry:';
|
|
17
17
|
const MAGIC_MODULE_WORKER = 'quilt:module/worker.js';
|
|
18
18
|
|
|
@@ -72,9 +72,11 @@ export interface Options {
|
|
|
72
72
|
inputOptions?: ValueOrUpdateGetter<InputOptions>;
|
|
73
73
|
outputOptions?: ValueOrUpdateGetter<OutputOptions>;
|
|
74
74
|
baseURL?: ValueOrGetter<string | undefined, BaseURLContext>;
|
|
75
|
+
format?: 'module' | 'classic';
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
export function workers({
|
|
79
|
+
format = 'classic',
|
|
78
80
|
write = false,
|
|
79
81
|
baseURL,
|
|
80
82
|
plugins = defaultPlugins,
|
|
@@ -135,8 +137,8 @@ export function workers({
|
|
|
135
137
|
: baseInputOptions;
|
|
136
138
|
|
|
137
139
|
const baseOutputOptions: OutputOptions = {
|
|
138
|
-
format: 'iife',
|
|
139
|
-
inlineDynamicImports:
|
|
140
|
+
format: format === 'classic' ? 'iife' : 'esm',
|
|
141
|
+
inlineDynamicImports: format === 'classic',
|
|
140
142
|
dir: 'workers',
|
|
141
143
|
entryFileNames: `[name].[hash].js`,
|
|
142
144
|
assetFileNames: `[name].[hash].[ext]`,
|
|
@@ -173,10 +175,10 @@ export function workers({
|
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
const filename = firstChunk.fileName;
|
|
176
|
-
let
|
|
178
|
+
let resolvedURL = filename;
|
|
177
179
|
|
|
178
180
|
if (typeof baseURL === 'string') {
|
|
179
|
-
|
|
181
|
+
resolvedURL = posix.join(baseURL, filename);
|
|
180
182
|
} else if (typeof baseURL === 'function') {
|
|
181
183
|
const returnedBaseURL = await baseURL({
|
|
182
184
|
...context,
|
|
@@ -186,11 +188,14 @@ export function workers({
|
|
|
186
188
|
});
|
|
187
189
|
|
|
188
190
|
if (returnedBaseURL) {
|
|
189
|
-
|
|
191
|
+
resolvedURL = posix.join(returnedBaseURL, filename);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
|
|
193
|
-
return `export default ${JSON.stringify(
|
|
195
|
+
return `export default ${JSON.stringify({
|
|
196
|
+
type: format,
|
|
197
|
+
source: resolvedURL,
|
|
198
|
+
})};`;
|
|
194
199
|
},
|
|
195
200
|
generateBundle(_, bundle) {
|
|
196
201
|
// We already wrote the chunks, no need to do it again I think?
|
|
@@ -204,7 +209,7 @@ export function workers({
|
|
|
204
209
|
};
|
|
205
210
|
}
|
|
206
211
|
|
|
207
|
-
|
|
212
|
+
function workerMagicModules() {
|
|
208
213
|
return {
|
|
209
214
|
name: '@quilted/workers/magic-modules',
|
|
210
215
|
resolveId(source) {
|
|
@@ -224,7 +229,7 @@ export function workerMagicModules() {
|
|
|
224
229
|
} satisfies Plugin;
|
|
225
230
|
}
|
|
226
231
|
|
|
227
|
-
|
|
232
|
+
function parseWorkerImport(
|
|
228
233
|
id: string,
|
|
229
234
|
prefix = PREFIX,
|
|
230
235
|
): WorkerContext | undefined {
|
|
@@ -241,7 +246,7 @@ export function parseWorkerImport(
|
|
|
241
246
|
};
|
|
242
247
|
}
|
|
243
248
|
|
|
244
|
-
|
|
249
|
+
function serializeWorkerImport(
|
|
245
250
|
{module, wrapper}: WorkerContext,
|
|
246
251
|
prefix = PREFIX,
|
|
247
252
|
) {
|
|
@@ -268,7 +273,7 @@ const KNOWN_WRAPPER_MODULES = new Map<string, Map<string, string>>([
|
|
|
268
273
|
['@quilted/quilt/threads', workerFunctionContent('@quilted/quilt/threads')],
|
|
269
274
|
]);
|
|
270
275
|
|
|
271
|
-
function contentForWorker({module, wrapper}: WorkerContext) {
|
|
276
|
+
export function contentForWorker({module, wrapper}: WorkerContext) {
|
|
272
277
|
const content = KNOWN_WRAPPER_MODULES.get(wrapper.module)?.get(
|
|
273
278
|
wrapper.function,
|
|
274
279
|
);
|
|
@@ -118,9 +118,7 @@ export async function targetsSupportModules(targets: readonly string[]) {
|
|
|
118
118
|
const {default: browserslist} = await import('browserslist');
|
|
119
119
|
|
|
120
120
|
return new Set(
|
|
121
|
-
browserslist(
|
|
122
|
-
'defaults and fully supports es6-module and fully supports es6-module-dynamic-import',
|
|
123
|
-
),
|
|
121
|
+
browserslist('defaults and fully supports es6-module-dynamic-import'),
|
|
124
122
|
);
|
|
125
123
|
})();
|
|
126
124
|
|
|
@@ -168,47 +166,21 @@ export async function rollupGenerateOptionsForBrowsers(
|
|
|
168
166
|
let objectShorthand = true;
|
|
169
167
|
let symbols = true;
|
|
170
168
|
|
|
171
|
-
const
|
|
172
|
-
browser: string,
|
|
173
|
-
version: import('semver').SemVer,
|
|
174
|
-
supportList: any,
|
|
175
|
-
) => {
|
|
176
|
-
const supportedVersionDetails = supportList[browser];
|
|
177
|
-
if (supportedVersionDetails == null) return false;
|
|
178
|
-
|
|
179
|
-
const supportedVersion = semver.coerce(
|
|
180
|
-
supportedVersionDetails.version_added,
|
|
181
|
-
);
|
|
182
|
-
if (supportedVersion == null) return false;
|
|
183
|
-
|
|
184
|
-
return semver.gte(version, supportedVersion);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
for (const browser of browsers) {
|
|
188
|
-
const [name, version] = browser.split(' ');
|
|
189
|
-
|
|
190
|
-
const semverVersion = semver.coerce(version);
|
|
191
|
-
if (semverVersion == null) continue;
|
|
192
|
-
|
|
193
|
-
const mdnBrowser = BROWSESLIST_BROWSER_TO_MDN_BROWSER.get(name!);
|
|
194
|
-
if (mdnBrowser == null) continue;
|
|
195
|
-
|
|
169
|
+
for (const {name, version} of mdnBrowserVersions(browsers, semver)) {
|
|
196
170
|
arrowFunctions &&= isSupported(
|
|
197
|
-
mdnBrowser,
|
|
198
|
-
semverVersion,
|
|
199
171
|
arrowFunctionsSupport,
|
|
172
|
+
name,
|
|
173
|
+
version,
|
|
174
|
+
semver,
|
|
200
175
|
);
|
|
201
|
-
constBindings &&= isSupported(
|
|
202
|
-
mdnBrowser,
|
|
203
|
-
semverVersion,
|
|
204
|
-
constBindingsSupport,
|
|
205
|
-
);
|
|
176
|
+
constBindings &&= isSupported(constBindingsSupport, name, version, semver);
|
|
206
177
|
objectShorthand &&= isSupported(
|
|
207
|
-
mdnBrowser,
|
|
208
|
-
semverVersion,
|
|
209
178
|
objectShorthandSupport,
|
|
179
|
+
name,
|
|
180
|
+
version,
|
|
181
|
+
semver,
|
|
210
182
|
);
|
|
211
|
-
symbols &&= isSupported(
|
|
183
|
+
symbols &&= isSupported(symbolsSupport, name, version, semver);
|
|
212
184
|
}
|
|
213
185
|
|
|
214
186
|
return {
|
|
@@ -220,3 +192,53 @@ export async function rollupGenerateOptionsForBrowsers(
|
|
|
220
192
|
symbols,
|
|
221
193
|
} satisfies import('rollup').GeneratedCodeOptions;
|
|
222
194
|
}
|
|
195
|
+
|
|
196
|
+
export async function targetsSupportModuleWebWorkers(
|
|
197
|
+
browsers: readonly string[],
|
|
198
|
+
) {
|
|
199
|
+
const [{default: semver}, {default: mdn}] = await Promise.all([
|
|
200
|
+
import('semver'),
|
|
201
|
+
import('@mdn/browser-compat-data', {
|
|
202
|
+
assert: {type: 'json'},
|
|
203
|
+
}) as Promise<any>,
|
|
204
|
+
]);
|
|
205
|
+
|
|
206
|
+
const workerModulesSupport =
|
|
207
|
+
mdn.api.Worker.Worker.ecmascript_modules.__compat.support;
|
|
208
|
+
|
|
209
|
+
return [...mdnBrowserVersions(browsers, semver)].every(({name, version}) =>
|
|
210
|
+
isSupported(workerModulesSupport, name, version, semver),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function* mdnBrowserVersions(
|
|
215
|
+
browsers: readonly string[],
|
|
216
|
+
semver: Pick<typeof import('semver'), 'coerce'>,
|
|
217
|
+
) {
|
|
218
|
+
for (const browser of browsers) {
|
|
219
|
+
const [name, version] = browser.split(' ');
|
|
220
|
+
|
|
221
|
+
const mdnBrowser = BROWSESLIST_BROWSER_TO_MDN_BROWSER.get(name!);
|
|
222
|
+
if (mdnBrowser == null) continue;
|
|
223
|
+
|
|
224
|
+
const semverVersion = semver.coerce(version);
|
|
225
|
+
if (semverVersion == null) continue;
|
|
226
|
+
|
|
227
|
+
yield {name: mdnBrowser, version: semverVersion};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function isSupported(
|
|
232
|
+
supportList: unknown,
|
|
233
|
+
browser: string,
|
|
234
|
+
version: import('semver').SemVer,
|
|
235
|
+
semver: Pick<typeof import('semver'), 'coerce' | 'gte'>,
|
|
236
|
+
) {
|
|
237
|
+
const supportedVersionDetails = (supportList as any)[browser];
|
|
238
|
+
if (supportedVersionDetails == null) return false;
|
|
239
|
+
|
|
240
|
+
const supportedVersion = semver.coerce(supportedVersionDetails.version_added);
|
|
241
|
+
if (supportedVersion == null) return false;
|
|
242
|
+
|
|
243
|
+
return semver.gte(version, supportedVersion);
|
|
244
|
+
}
|