wc-compiler 0.3.1 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wc-compiler",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Experimental native Web Components compiler.",
5
5
  "main": "src/wcc.js",
6
6
  "type": "module",
@@ -10,12 +10,14 @@
10
10
  "node": ">=14"
11
11
  },
12
12
  "files": [
13
- "src/"
13
+ "src/",
14
+ "dist/wcc.dist.js"
14
15
  ],
15
16
  "publishConfig": {
16
17
  "access": "public"
17
18
  },
18
19
  "scripts": {
20
+ "clean": "rimraf ./dist",
19
21
  "lint": "eslint \"*.*js\" \"./src/**/**/*.js\" \"./test/**/**/*.js\"",
20
22
  "develop": "concurrently \"nodemon --watch src --watch docs -e js,md,css,html ./build.js\" \"http-server ./dist --open\"",
21
23
  "build": "node ./build.js",
@@ -24,7 +26,9 @@
24
26
  "example:ssr": "node ./examples/ssr.js",
25
27
  "start": "npm run develop",
26
28
  "test": "c8 mocha --parallel",
27
- "test:tdd": "npm run test --watch"
29
+ "test:tdd": "npm run test --watch",
30
+ "dist": "rollup -c rollup.config.js",
31
+ "prepublishOnly": "npm run clean && npm run dist"
28
32
  },
29
33
  "dependencies": {
30
34
  "acorn": "^8.7.0",
@@ -33,6 +37,8 @@
33
37
  },
34
38
  "devDependencies": {
35
39
  "@mapbox/rehype-prism": "^0.8.0",
40
+ "@rollup/plugin-commonjs": "^22.0.0",
41
+ "@rollup/plugin-node-resolve": "^13.3.0",
36
42
  "c8": "^7.11.2",
37
43
  "chai": "^4.3.6",
38
44
  "concurrently": "^7.1.0",
@@ -49,6 +55,8 @@
49
55
  "remark-parse": "^10.0.1",
50
56
  "remark-rehype": "^10.1.0",
51
57
  "remark-toc": "^8.0.1",
58
+ "rimraf": "^3.0.2",
59
+ "rollup": "^2.75.7",
52
60
  "simple.css": "^0.1.3",
53
61
  "unified": "^10.1.2"
54
62
  }
package/src/wcc.js CHANGED
@@ -4,8 +4,7 @@ import './dom-shim.js';
4
4
  import * as acorn from 'acorn';
5
5
  import * as walk from 'acorn-walk';
6
6
  import { parse, parseFragment, serialize } from 'parse5';
7
-
8
- import fs from 'node:fs/promises';
7
+ import fs from 'fs/promises';
9
8
 
10
9
  let definitions;
11
10
 
@@ -105,10 +104,12 @@ async function getTagName(moduleURL) {
105
104
  async function initializeCustomElement(elementURL, tagName, attrs = []) {
106
105
  await registerDependencies(elementURL);
107
106
 
107
+ // https://github.com/ProjectEvergreen/wcc/pull/67/files#r902061804
108
+ const { pathname } = elementURL;
108
109
  const element = tagName
109
110
  ? customElements.get(tagName)
110
- : (await import(elementURL)).default;
111
- const dataLoader = (await import(elementURL)).getData;
111
+ : (await import(pathname)).default;
112
+ const dataLoader = (await import(pathname)).getData;
112
113
  const data = dataLoader ? await dataLoader() : {};
113
114
  const elementInstance = new element(data); // eslint-disable-line new-cap
114
115