@webqit/webflo 0.20.13-next.0 → 0.20.13
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
CHANGED
package/src/build-pi/index.js
CHANGED
|
@@ -155,7 +155,7 @@ async function bundleScript({ $context, $source, which, outfile, asModule = true
|
|
|
155
155
|
plugins: [UseLiveTransform()],
|
|
156
156
|
...(restParams.buildParams || {})
|
|
157
157
|
};
|
|
158
|
-
if (
|
|
158
|
+
if (asModule && which !== 'server') {
|
|
159
159
|
// Support top-level await
|
|
160
160
|
// See: https://github.com/evanw/esbuild/issues/253#issuecomment-826147115
|
|
161
161
|
bundlingConfig.banner.js += '(async () => {';
|
|
@@ -11,7 +11,7 @@ export class ClientSideWorkport extends EventTarget {
|
|
|
11
11
|
|
|
12
12
|
static async initialize(parentNode, file, params = {}) {
|
|
13
13
|
const registration = (await navigator.serviceWorker.getRegistration())
|
|
14
|
-
|| (await navigator.serviceWorker.register(file, { scope: '/', ...params }));
|
|
14
|
+
|| (await navigator.serviceWorker.register(file, { scope: '/', type: 'module', ...params }));
|
|
15
15
|
return new this(parentNode, registration, params);
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import Fs from 'fs/promises';
|
|
2
|
-
import { parse, compile, matchPrologDirective, serialize } from '@webqit/use-live';
|
|
3
|
-
|
|
4
|
-
export function UseLiveTransform() {
|
|
5
|
-
return {
|
|
6
|
-
name: 'uselive-transform',
|
|
7
|
-
setup(build) {
|
|
8
|
-
build.onLoad({ filter: /\.(js|mjs|ts|jsx|tsx)$/ }, async (args) => {
|
|
9
|
-
const code = await Fs.readFile(args.path, 'utf8');
|
|
10
|
-
|
|
11
|
-
// Super dirty detection
|
|
12
|
-
if (matchPrologDirective(code)) {
|
|
13
|
-
// Actual check...
|
|
14
|
-
|
|
15
|
-
let ast;
|
|
16
|
-
try { ast = parse(code, parserParams); } catch (e) { console.error(args.path, '\nUseLive transform error:', e); }
|
|
17
|
-
|
|
18
|
-
if (ast?.isLiveProgram || ast?.hasLiveFunctions) {
|
|
19
|
-
const result = await compile(parserParams.sourceType+'-file', ast, {
|
|
20
|
-
liveMode: ast.isLiveProgram, // Regarding top-level
|
|
21
|
-
fileName: args.path,
|
|
22
|
-
});
|
|
23
|
-
return { contents: serialize(result), loader: 'js' };
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return { contents: code, loader: 'default' };
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const parserParams = {
|
|
34
|
-
ecmaVersion: 'latest',
|
|
35
|
-
sourceType: 'module',
|
|
36
|
-
executionMode: 'RegularProgram', // 'LiveProgram'
|
|
37
|
-
allowReturnOutsideFunction: true,
|
|
38
|
-
allowAwaitOutsideFunction: true,
|
|
39
|
-
allowSuperOutsideMethod: false,
|
|
40
|
-
preserveParens: false,
|
|
41
|
-
locations: true,
|
|
42
|
-
};
|