olum-compiler 1.9.4 → 1.9.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/bin/bundle.js +2 -0
- package/bin/copySrc.js +6 -1
- package/lib/changes.txt +0 -8
- package/lib/helpers.js +3 -3
- package/lib/parser.js +8 -12
- package/package.json +1 -1
- package/tests/compiler.test.js +4 -0
package/bin/bundle.js
CHANGED
package/bin/copySrc.js
CHANGED
|
@@ -31,9 +31,14 @@ function injectIndexHtml(indexHtmlPath) {
|
|
|
31
31
|
|
|
32
32
|
const importMapTag =
|
|
33
33
|
process.env.NODE_ENV === "production" ? "" : `${importMap(entryPoint)}\n`;
|
|
34
|
+
|
|
35
|
+
const devFlagTag =
|
|
36
|
+
process.env.NODE_ENV === "production"
|
|
37
|
+
? ""
|
|
38
|
+
: `<script>globalThis.__OLUM_DEV__ = true;</script>\n`;
|
|
34
39
|
indexHtmlContent = indexHtmlContent.replace(
|
|
35
40
|
/<\/body>/,
|
|
36
|
-
`\n<div id="app"></div>\n${importMapTag}<script defer type="module" src="../src/main.js"></script>\n${devtoolScriptContent}</body>`,
|
|
41
|
+
`\n<div id="app"></div>\n${devFlagTag}${importMapTag}<script defer type="module" src="../src/main.js"></script>\n${devtoolScriptContent}</body>`,
|
|
37
42
|
);
|
|
38
43
|
fs.writeFileSync(indexHtmlPath, indexHtmlContent);
|
|
39
44
|
}
|
package/lib/changes.txt
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
change /tmp/olum-dev-test-dNAask/src/page.html
|
|
2
|
-
change /tmp/olum-dev-test-dNAask/public/main.css
|
|
3
|
-
addDir /tmp/olum-dev-test-dNAask/src/blog
|
|
4
|
-
add /tmp/olum-dev-test-dNAask/src/blog/page.html
|
|
5
|
-
unlink /tmp/olum-dev-test-dNAask/src/blog/page.html
|
|
6
|
-
unlinkDir /tmp/olum-dev-test-dNAask/src/blog
|
|
7
|
-
change /tmp/olum-dev-test-dNAask/src/util.js
|
|
8
|
-
change /tmp/olum-dev-test-dNAask/src/page.html
|
package/lib/helpers.js
CHANGED
|
@@ -312,7 +312,7 @@ function createScopeHandler({
|
|
|
312
312
|
if (hasState && isFullArr(stateProps)) {
|
|
313
313
|
let fragments = stateProps.map((prop) => prop + ": state." + prop);
|
|
314
314
|
arr.push(
|
|
315
|
-
`get state(){return
|
|
315
|
+
`get state(){return olum.proxyHandlerForScope(${"{" + fragments.join(",") + "}"}, state);}`,
|
|
316
316
|
);
|
|
317
317
|
}
|
|
318
318
|
return arr;
|
|
@@ -365,7 +365,7 @@ function createScopeHandler({
|
|
|
365
365
|
(prop) => prop + ": state." + prop,
|
|
366
366
|
);
|
|
367
367
|
arr.push(
|
|
368
|
-
`get state(){return
|
|
368
|
+
`get state(){return olum.proxyHandlerForScope(${"{" + fragments.join(",") + "}"}, state);}`,
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
@@ -407,7 +407,7 @@ function createScopeHandler({
|
|
|
407
407
|
(prop) => prop + ": state." + prop,
|
|
408
408
|
);
|
|
409
409
|
arr.push(
|
|
410
|
-
`get state(){return
|
|
410
|
+
`get state(){return olum.proxyHandlerForScope(${"{" + fragments.join(",") + "}"}, state);}`,
|
|
411
411
|
);
|
|
412
412
|
}
|
|
413
413
|
}
|
package/lib/parser.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const isDev = true;
|
|
2
|
-
|
|
3
1
|
const splitSFC = require("./sfc");
|
|
4
2
|
const htmlParser = require("./htmlParser");
|
|
5
3
|
const cssParser = require("./cssParser");
|
|
@@ -21,6 +19,8 @@ const createSourceMap = require("./sourcemap");
|
|
|
21
19
|
const liveProps = require("./liveProps");
|
|
22
20
|
const usage = require("./usage");
|
|
23
21
|
|
|
22
|
+
const RUNTIME_IMPORT = `import __olumPkg from "olum";const olum=__olumPkg.__olum||window.olum;`;
|
|
23
|
+
|
|
24
24
|
const parser = (str, counter, filePath) => {
|
|
25
25
|
const sfc = splitSFC(str, filePath);
|
|
26
26
|
|
|
@@ -202,15 +202,11 @@ const parser = (str, counter, filePath) => {
|
|
|
202
202
|
__OLUM__: olum_${currentID},
|
|
203
203
|
el: el_${currentID},
|
|
204
204
|
methodsRef: methods_${currentID},
|
|
205
|
-
|
|
206
|
-
${
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
.map((name) => `get ${name}(){return ${name}}`)
|
|
211
|
-
.join(",")}},`
|
|
212
|
-
: ""
|
|
213
|
-
}
|
|
205
|
+
stateProps: ${hasState ? "state" : "null"},
|
|
206
|
+
localsRef: {${globalProps
|
|
207
|
+
.filter((name) => name !== "state")
|
|
208
|
+
.map((name) => `get ${name}(){return ${name}}`)
|
|
209
|
+
.join(",")}},
|
|
214
210
|
hooks: {
|
|
215
211
|
mounted: typeof mounted !== "undefined" ? mounted : null,
|
|
216
212
|
unMounted: null,
|
|
@@ -218,7 +214,7 @@ const parser = (str, counter, filePath) => {
|
|
|
218
214
|
isUnMounted: false,
|
|
219
215
|
}
|
|
220
216
|
};
|
|
221
|
-
}
|
|
217
|
+
};${RUNTIME_IMPORT}`;
|
|
222
218
|
|
|
223
219
|
try {
|
|
224
220
|
out = liveProps(out);
|
package/package.json
CHANGED
package/tests/compiler.test.js
CHANGED
|
@@ -22,6 +22,10 @@ function compile(template) {
|
|
|
22
22
|
function parses(out) {
|
|
23
23
|
const body = out
|
|
24
24
|
.replace(/^\s*import .*$/gm, "")
|
|
25
|
+
.replace(
|
|
26
|
+
/import __olumPkg from "olum";const olum=__olumPkg\.__olum\|\|window\.olum;/g,
|
|
27
|
+
"",
|
|
28
|
+
)
|
|
25
29
|
.replace(/^\s*export\s+default\s+/m, "const __x=");
|
|
26
30
|
new Function(body);
|
|
27
31
|
return true;
|