Skip to content

Commit 3277826

Browse files
committed
Remove all templates code from code-input.js when buillding
1 parent 85a9219 commit 3277826

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

code-input.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ var codeInput = {
209209
plugins = [];
210210
},
211211

212-
// ESM-SUPPORT-START-TEMPLATES Do not (re)move this - it's needed for ESM generation!
212+
// ESM-SUPPORT-START-TEMPLATES-BLOCK-1 Do not (re)move this - it's needed for ESM generation!
213213
/**
214214
* For creating a custom template from scratch, please
215215
* use `new codeInput.Template(...)`
@@ -312,7 +312,7 @@ var codeInput = {
312312
};
313313
},
314314
},
315-
// ESM-SUPPORT-END-TEMPLATES Do not (re)move this - it's needed for ESM generation!
315+
// ESM-SUPPORT-END-TEMPLATES-BLOCK-1 Do not (re)move this - it's needed for ESM generation!
316316

317317
/* ------------------------------------
318318
* ------------Plugins-----------------
@@ -1041,6 +1041,7 @@ var codeInput = {
10411041
}
10421042
}
10431043

1044+
// ESM-SUPPORT-START-TEMPLATES-BLOCK-2 Do not (re)move this - it's needed for ESM generation!
10441045
{
10451046
// Templates are defined here after the codeInput variable is set, because they reference it by extending codeInput.Template.
10461047

@@ -1095,5 +1096,6 @@ var codeInput = {
10951096
// ESM-SUPPORT-END-TEMPLATE-hljs Do not (re)move this - it's needed for ESM generation!
10961097
codeInput.templates.Hljs = Hljs;
10971098
}
1099+
// ESM-SUPPORT-END-TEMPLATES-BLOCK-2 Do not (re)move this - it's needed for ESM generation!
10981100

10991101
customElements.define("code-input", codeInput.CodeInput);

esm/generate.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ const AUTOGENERATED_NOTICE = "// NOTICE: This code is @generated from code outsi
1818
// Miss out templates
1919
let copyingCode = true;
2020
for await (const line of codeInputJs.readLines()) {
21-
if(line.includes("ESM-SUPPORT-START-TEMPLATES")) {
21+
if(line.includes("ESM-SUPPORT-START-TEMPLATES-BLOCK-1") || line.includes("ESM-SUPPORT-START-TEMPLATES-BLOCK-2")) {
2222
copyingCode = false;
2323
}
2424
if(copyingCode) {
2525
await codeInputMjs.writeFile(line+"\n");
2626
}
27-
if(line.includes("ESM-SUPPORT-END-TEMPLATES")) {
27+
if(line.includes("ESM-SUPPORT-END-TEMPLATES-BLOCK-1") || line.includes("ESM-SUPPORT-END-TEMPLATES-BLOCK-2")) {
2828
copyingCode = true; // After code to copy - this line missed out
2929
}
3030
}

esm/generate.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ AUTOGENERATED_NOTICE="// NOTICE: This code is @generated from code outside the e
99
echo $AUTOGENERATED_NOTICE > code-input.mjs
1010
echo "" >> code-input.mjs
1111
# Imports: Nothing
12-
# Code before templates
13-
head -$(($(sed -n "/ESM-SUPPORT-START-TEMPLATES/=" ../code-input.js | head -1) - 1)) ../code-input.js >> code-input.mjs
14-
# Miss out templates
15-
# Code after templates
16-
tail --line=+$(($(sed -n "/ESM-SUPPORT-END-TEMPLATES/=" ../code-input.js | head -1) + 1)) ../code-input.js >> code-input.mjs
12+
# Code before first templates block
13+
head -$(($(sed -n "/ESM-SUPPORT-START-TEMPLATES-BLOCK-1/=" ../code-input.js | head -1) - 1)) ../code-input.js >> code-input.mjs
14+
# Code before second templates block, after first templates block
15+
head -$(($(sed -n "/ESM-SUPPORT-START-TEMPLATES-BLOCK-2/=" ../code-input.js | head -1) - 1)) ../code-input.js | tail --line=+$(($(sed -n "/ESM-SUPPORT-END-TEMPLATES-BLOCK-1/=" ../code-input.js | head -1) + 1)) >> code-input.mjs
16+
# Code after second templates block
17+
tail --line=+$(($(sed -n "/ESM-SUPPORT-END-TEMPLATES-BLOCK-2/=" ../code-input.js | head -1) + 1)) ../code-input.js >> code-input.mjs
1718
# Exports
1819
echo "export const Plugin = codeInput.Plugin;" >> code-input.mjs
1920
echo "export const Template = codeInput.Template;" >> code-input.mjs

0 commit comments

Comments
 (0)