wc-compiler 0.6.0 → 0.6.1
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 +1 -1
- package/dist/wcc.dist.cjs +5 -2
- package/package.json +4 -4
- package/src/wcc.js +6 -2
package/README.md
CHANGED
|
@@ -88,4 +88,4 @@ See our [website](https://merry-caramel-524e61.netlify.app/) for API docs and ex
|
|
|
88
88
|
|
|
89
89
|
**WCC** is not a static site generator, framework or bundler. It is focused on producing raw HTML from Web Components with the intent of being easily integrated into a site generator or framework, like [**Greenwood**](https://github.com/ProjectEvergreen/greenwood/) or [**Eleventy**](https://github.com/ProjectEvergreen/eleventy-plugin-wcc/), the original motivation for creating [this project](https://github.com/ProjectEvergreen/greenwood/issues/935).
|
|
90
90
|
|
|
91
|
-
In addition, **WCC** hopes to provide a surface area to explore patterns around [streaming](https://github.com/ProjectEvergreen/wcc/issues/5) and
|
|
91
|
+
In addition, **WCC** hopes to provide a surface area to explore patterns around [streaming](https://github.com/ProjectEvergreen/wcc/issues/5), [serverless and edge rendering](https://github.com/thescientist13/web-components-at-the-edge), and as acting as a test bed for the [Web Components Community Groups](https://github.com/webcomponents-cg)'s discussions around community protocols, like [hydration](https://github.com/ProjectEvergreen/wcc/issues/3).
|
package/dist/wcc.dist.cjs
CHANGED
|
@@ -27934,7 +27934,8 @@ function registerDependencies(moduleURL, definitions, depth = 0) {
|
|
|
27934
27934
|
const specifier = node.source.value;
|
|
27935
27935
|
const isBareSpecifier = specifier.indexOf('.') !== 0 && specifier.indexOf('/') !== 0;
|
|
27936
27936
|
|
|
27937
|
-
|
|
27937
|
+
// TODO would like to decouple .jsx from the core, ideally
|
|
27938
|
+
if (!isBareSpecifier && ['.js', '.jsx'].includes(path__default["default"].extname(specifier))) {
|
|
27938
27939
|
const dependencyModuleURL = new URL(node.source.value, moduleURL);
|
|
27939
27940
|
|
|
27940
27941
|
registerDependencies(dependencyModuleURL, definitions, nextDepth);
|
|
@@ -27943,7 +27944,9 @@ function registerDependencies(moduleURL, definitions, depth = 0) {
|
|
|
27943
27944
|
ExpressionStatement(node) {
|
|
27944
27945
|
if (isCustomElementDefinitionNode(node)) {
|
|
27945
27946
|
const { arguments: args } = node.expression;
|
|
27946
|
-
const tagName = args[0].
|
|
27947
|
+
const tagName = args[0].type === 'Literal'
|
|
27948
|
+
? args[0].value // single and double quotes
|
|
27949
|
+
: args[0].quasis[0].value.raw; // template literal
|
|
27947
27950
|
const tree = parseJsx(moduleURL);
|
|
27948
27951
|
const isEntry = nextDepth - 1 === 1;
|
|
27949
27952
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wc-compiler",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Experimental native Web Components compiler.",
|
|
5
5
|
"main": "src/wcc.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"build": "node ./build.js",
|
|
24
24
|
"serve": "node ./build.js && http-server ./dist --open",
|
|
25
25
|
"start": "npm run develop",
|
|
26
|
-
"test": "mocha --exclude \"./test/cases/jsx/**\" \"./test/**/**/*.spec.js\"",
|
|
27
|
-
"test:
|
|
26
|
+
"test": "mocha --exclude \"./test/cases/jsx/**\" --exclude \"./test/cases/custom-extension/**\" \"./test/**/**/*.spec.js\"",
|
|
27
|
+
"test:exp": "c8 node --experimental-loader ./test-exp-loader.js ./node_modules/mocha/bin/mocha \"./test/**/**/*.spec.js\"",
|
|
28
28
|
"test:tdd": "npm run test -- --watch",
|
|
29
|
-
"test:tdd:
|
|
29
|
+
"test:tdd:exp": "npm run test:exp -- --watch",
|
|
30
30
|
"dist": "rollup -c rollup.config.js",
|
|
31
31
|
"prepublishOnly": "npm run clean && npm run dist"
|
|
32
32
|
},
|
package/src/wcc.js
CHANGED
|
@@ -8,6 +8,7 @@ import escodegen from 'escodegen';
|
|
|
8
8
|
import { getParser, parseJsx } from './jsx-loader.js';
|
|
9
9
|
import { parse, parseFragment, serialize } from 'parse5';
|
|
10
10
|
import fs from 'fs';
|
|
11
|
+
import path from 'path';
|
|
11
12
|
|
|
12
13
|
function getParse(html) {
|
|
13
14
|
return html.indexOf('<html>') >= 0 || html.indexOf('<body>') >= 0 || html.indexOf('<head>') >= 0
|
|
@@ -74,7 +75,8 @@ function registerDependencies(moduleURL, definitions, depth = 0) {
|
|
|
74
75
|
const specifier = node.source.value;
|
|
75
76
|
const isBareSpecifier = specifier.indexOf('.') !== 0 && specifier.indexOf('/') !== 0;
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
// TODO would like to decouple .jsx from the core, ideally
|
|
79
|
+
if (!isBareSpecifier && ['.js', '.jsx'].includes(path.extname(specifier))) {
|
|
78
80
|
const dependencyModuleURL = new URL(node.source.value, moduleURL);
|
|
79
81
|
|
|
80
82
|
registerDependencies(dependencyModuleURL, definitions, nextDepth);
|
|
@@ -83,7 +85,9 @@ function registerDependencies(moduleURL, definitions, depth = 0) {
|
|
|
83
85
|
ExpressionStatement(node) {
|
|
84
86
|
if (isCustomElementDefinitionNode(node)) {
|
|
85
87
|
const { arguments: args } = node.expression;
|
|
86
|
-
const tagName = args[0].
|
|
88
|
+
const tagName = args[0].type === 'Literal'
|
|
89
|
+
? args[0].value // single and double quotes
|
|
90
|
+
: args[0].quasis[0].value.raw; // template literal
|
|
87
91
|
const tree = parseJsx(moduleURL);
|
|
88
92
|
const isEntry = nextDepth - 1 === 1;
|
|
89
93
|
|