-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standalone content-tag implemented via conditional exports in
package.json
- Loading branch information
1 parent
a396fcf
commit 3d4ee8d
Showing
20 changed files
with
5,530 additions
and
1,125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
pkg/node/ | ||
index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
/target | ||
/node_modules | ||
/node_modules | ||
|
||
pkg/node/ | ||
pkg/standalone/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# we need npm packages for the post-wasm phase | ||
npm install | ||
|
||
rm -rf pkg/node | ||
rm -rf pkg/standalone | ||
|
||
# wasm-pack knows to use wasm-opt, when present | ||
# NOTE: wasm-pack does not support multi-target building | ||
# so we'll build twice, and then tweak package.json | ||
# "exports" to point at the correct build depending on node or browser | ||
wasm-pack build --target web --out-dir pkg/standalone --weak-refs --no-pack --release | ||
wasm-pack build --target nodejs --out-dir pkg/node --weak-refs --no-pack --release | ||
|
||
# Rename the node js file to cjs, because we emit type=module | ||
mv pkg/node/content_tag.js pkg/node/content_tag.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* wasm-pack doesn't give us correct enough types. | ||
*/ | ||
|
||
|
||
|
||
interface Parsed { | ||
type: 'expression' | 'class-member'; | ||
tagName: 'template'; | ||
contents: string; | ||
range: { | ||
start: number; | ||
end: number; | ||
}; | ||
contentRange: { | ||
start: number; | ||
end: number; | ||
}; | ||
startRange: { | ||
end: number; | ||
start: number; | ||
}; | ||
endRange: { | ||
start: number; | ||
end: number; | ||
}; | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
export class Preprocessor { | ||
free(): void; | ||
/** | ||
*/ | ||
constructor(); | ||
/** | ||
* @param {string} src | ||
* @param {string | undefined} filename | ||
* @returns {string} | ||
*/ | ||
process(src: string, filename?: string): string; | ||
/** | ||
* @param {string} src | ||
* @param {string | undefined} filename | ||
* @returns {any} | ||
*/ | ||
parse(src: string, filename?: string): Parsed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
|
||
<!-- View this file with `npm run web` --> | ||
|
||
<head> | ||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> | ||
<script type="module"> | ||
import {Preprocessor} from 'content-tag'; | ||
|
||
const p = new Preprocessor(); | ||
const output = p.process('<template>Hi from createPreprocessor</template>'); | ||
|
||
document.querySelector('#output').innerHTML = output; | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<pre id="output"></pre> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.