Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
"scripts": {
"benchmark:w3c": "node test/benchmark/linkedom.js --w3c; node test/benchmark/linkedom-cached.js --w3c; node test/benchmark/dom.js --w3c",
"benchmark:dom": "node test/benchmark/linkedom.js --dom; node test/benchmark/linkedom-cached.js --dom; node test/benchmark/dom.js --dom",
"build": "npm run rollup:es && node rollup/init.cjs && npm run rollup:init && rm -rf cjs/* && npm run cjs && rm -rf types && npm run ts && npm run test && npm run size",
"build": "npm run rollup:es && node rollup/init.cjs && npm run rollup:init && rm -rf cjs/* && npm run cjs && npm run test && npm run size",
"cjs": "ascjs --no-default esm cjs",
"rollup:es": "rollup --config rollup/es.config.js",
"rollup:init": "rollup --config rollup/init.config.js",
"server": "npx static-handler .",
"size": "echo \"index $(cat index.js | brotli | wc -c)\";echo \"keyed $(cat keyed.js | brotli | wc -c)\";echo \"reactive $(cat reactive.js | brotli | wc -c)\";echo \"preactive $(cat preactive.js | brotli | wc -c)\";echo \"signal $(cat signal.js | brotli | wc -c)\";echo \"node $(cat node.js | brotli | wc -c)\";",
"test": "c8 node test/coverage.js && node test/modern.mjs",
"coverage": "mkdir -p ./coverage; c8 report --reporter=text-lcov > ./coverage/lcov.info",
"ts": "tsc -p ."
"coverage": "mkdir -p ./coverage; c8 report --reporter=text-lcov > ./coverage/lcov.info"
},
"keywords": [
"micro",
Expand All @@ -29,43 +28,36 @@
"ascjs": "^6.0.3",
"c8": "^9.1.0",
"rollup": "^4.13.2",
"typescript": "^5.4.3"
"typescript": "^5.4.5"
},
"module": "./esm/index.js",
"type": "module",
"exports": {
".": {
"types": "./types/index.d.ts",
"import": "./esm/index.js",
"default": "./cjs/index.js"
},
"./dom": {
"types": "./types/dom/index.d.ts",
"import": "./esm/dom/index.js",
"default": "./cjs/dom/index.js"
},
"./init": {
"types": "./types/init.d.ts",
"import": "./esm/init.js",
"default": "./cjs/init.js"
},
"./keyed": {
"types": "./types/keyed.d.ts",
"import": "./esm/keyed.js",
"default": "./cjs/keyed.js"
},
"./node": {
"types": "./types/node.d.ts",
"import": "./esm/node.js",
"default": "./cjs/node.js"
},
"./reactive": {
"types": "./types/reactive.d.ts",
"import": "./esm/reactive.js",
"default": "./cjs/reactive.js"
},
"./preactive": {
"types": "./types/reactive/preact.d.ts",
"import": "./esm/reactive/preact.js",
"default": "./cjs/reactive/preact.js"
},
Expand Down
10 changes: 10 additions & 0 deletions rollup/init.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ export default document => ${
.replace(/^(\s+)replaceWith\(([^}]+?)\}/m, '$1/* c8 ignore start */\n$1replaceWith($2}\n$1/* c8 ignore stop */')
.replace(/^(\s+)(["'])use strict\2;/m, '$1$2use strict$2;\n\n$1const { constructor: DocumentFragment } = document.createDocumentFragment();')
.replace(/^[^(]+/, '')
.replace(/\n exports\.Hole = Hole;[\S\s]*return exports;/m, `
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what has this to do with this MR?

Copy link
Contributor Author

@iacore iacore Apr 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fixes type hints of uhtml/init. Without this, const { html, render } = init(document) will not have types (or rather be any). See https://git.envs.net/iacore/data-soup/src/commit/fc8fbb1bb35d071caf01963e53716d95cc4ddf79/server.js#L19

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK ... then we need to do a bit more ... to start with, the exports object is not needed, we need to replace that too. I now need to maintain manually all exports in this file + it's not clear once we remove tsc what is typescript dependency doing in here at all ... this feels like a breaking change too ... thoughts?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this line feels particularly cumbersome render : keyed$1,

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm ... I think this is landing in here with better logic to let me publish more than just init.js there: #114

return {
Hole : Hole,
attr : attr,
html : html,
htmlFor : htmlFor,
render : keyed$1,
svg : svg,
svgFor : svgFor,
};`)
}`);
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"moduleResolution": "nodenext",
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"declarationDir": "types"
//"emitDeclarationOnly": true,
"noEmit": true,
},
"include": [
"esm/index.js",
Expand Down