wc-compiler 0.7.0 → 0.8.0

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/dist/wcc.dist.cjs CHANGED
@@ -27629,8 +27629,6 @@ var serialize = function(node, options) {
27629
27629
 
27630
27630
  /* eslint-disable max-depth, complexity */
27631
27631
 
27632
- new URL(`file://${process.cwd()}/`);
27633
-
27634
27632
  // TODO same hack as definitions
27635
27633
  // https://github.com/ProjectEvergreen/wcc/discussions/74
27636
27634
  let string;
@@ -27833,7 +27831,7 @@ function findThisReferences(context, statement) {
27833
27831
  } else if (isRenderFunctionContext && type === 'VariableDeclaration') {
27834
27832
  statement.declarations.forEach(declaration => {
27835
27833
  const { init, id } = declaration;
27836
-
27834
+
27837
27835
  if (init.object && init.object.type === 'ThisExpression') {
27838
27836
  // const { description } = this.todo;
27839
27837
  references.push(init.property.name);
@@ -28134,9 +28132,9 @@ async function initializeCustomElement(elementURL, tagName, attrs = [], definiti
28134
28132
  }
28135
28133
  }
28136
28134
 
28137
- async function renderToString(elementURL) {
28135
+ async function renderToString(elementURL, wrappingEntryTag = true) {
28138
28136
  const definitions = [];
28139
- const elementTagName = await getTagName(elementURL);
28137
+ const elementTagName = wrappingEntryTag && await getTagName(elementURL);
28140
28138
  const isEntry = !!elementTagName;
28141
28139
  const elementInstance = await initializeCustomElement(elementURL, undefined, undefined, definitions, isEntry);
28142
28140
 
@@ -28145,7 +28143,7 @@ async function renderToString(elementURL) {
28145
28143
  : elementInstance.innerHTML;
28146
28144
  const elementTree = getParse(elementHtml)(elementHtml);
28147
28145
  const finalTree = await renderComponentRoots(elementTree, definitions);
28148
- const html = elementTagName ? `
28146
+ const html = wrappingEntryTag && elementTagName ? `
28149
28147
  <${elementTagName}>
28150
28148
  ${serialize(finalTree)}
28151
28149
  </${elementTagName}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wc-compiler",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Experimental native Web Components compiler.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "scripts": {
29
29
  "clean": "rimraf ./dist",
30
- "lint": "eslint \"*.*js\" \"./src/**/**/*.js*\" \"./test/**/**/*.js*\"",
30
+ "lint": "ls-lint && eslint \"*.*js\" \"./src/**/**/*.js*\" \"./docs/**/*.md\" \"./test/**/**/*.js*\"",
31
31
  "develop": "concurrently \"nodemon --watch src --watch docs -e js,md,css,html,jsx ./build.js\" \"http-server ./dist --open\"",
32
32
  "build": "node ./build.js",
33
33
  "serve": "node ./build.js && http-server ./dist --open",
@@ -47,6 +47,7 @@
47
47
  "parse5": "^6.0.1"
48
48
  },
49
49
  "devDependencies": {
50
+ "@ls-lint/ls-lint": "^1.10.0",
50
51
  "@mapbox/rehype-prism": "^0.8.0",
51
52
  "@rollup/plugin-commonjs": "^22.0.0",
52
53
  "@rollup/plugin-json": "^4.1.0",
@@ -55,6 +56,8 @@
55
56
  "chai": "^4.3.6",
56
57
  "concurrently": "^7.1.0",
57
58
  "eslint": "^8.14.0",
59
+ "eslint-plugin-markdown": "^3.0.0",
60
+ "eslint-plugin-no-only-tests": "^2.6.0",
58
61
  "http-server": "^14.1.0",
59
62
  "jsdom": "^19.0.0",
60
63
  "mocha": "^9.2.2",
package/src/jsx-loader.js CHANGED
@@ -7,7 +7,6 @@ import fs from 'fs';
7
7
  import jsx from 'acorn-jsx';
8
8
  import { parse, parseFragment, serialize } from 'parse5';
9
9
 
10
- const baseURL = new URL(`file://${process.cwd()}/`);
11
10
  const jsxRegex = /\.(jsx)$/;
12
11
 
13
12
  // TODO same hack as definitions
@@ -212,7 +211,7 @@ function findThisReferences(context, statement) {
212
211
  } else if (isRenderFunctionContext && type === 'VariableDeclaration') {
213
212
  statement.declarations.forEach(declaration => {
214
213
  const { init, id } = declaration;
215
-
214
+
216
215
  if (init.object && init.object.type === 'ThisExpression') {
217
216
  // const { description } = this.todo;
218
217
  references.push(init.property.name);
@@ -363,11 +362,12 @@ export function parseJsx(moduleURL) {
363
362
  // --------------
364
363
 
365
364
  export function resolve(specifier, context, defaultResolve) {
366
- const { parentURL = baseURL } = context;
365
+ const { parentURL } = context;
367
366
 
368
367
  if (jsxRegex.test(specifier)) {
369
368
  return {
370
- url: new URL(specifier, parentURL).href
369
+ url: new URL(specifier, parentURL).href,
370
+ shortCircuit: true
371
371
  };
372
372
  }
373
373
 
package/src/wcc.js CHANGED
@@ -160,9 +160,9 @@ async function initializeCustomElement(elementURL, tagName, attrs = [], definiti
160
160
  }
161
161
  }
162
162
 
163
- async function renderToString(elementURL) {
163
+ async function renderToString(elementURL, wrappingEntryTag = true) {
164
164
  const definitions = [];
165
- const elementTagName = await getTagName(elementURL);
165
+ const elementTagName = wrappingEntryTag && await getTagName(elementURL);
166
166
  const isEntry = !!elementTagName;
167
167
  const elementInstance = await initializeCustomElement(elementURL, undefined, undefined, definitions, isEntry);
168
168
 
@@ -171,7 +171,7 @@ async function renderToString(elementURL) {
171
171
  : elementInstance.innerHTML;
172
172
  const elementTree = getParse(elementHtml)(elementHtml);
173
173
  const finalTree = await renderComponentRoots(elementTree, definitions);
174
- const html = elementTagName ? `
174
+ const html = wrappingEntryTag && elementTagName ? `
175
175
  <${elementTagName}>
176
176
  ${serialize(finalTree)}
177
177
  </${elementTagName}>