-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve serialization across multiple writes (#1542)
* feat: improve serialization across multiple writes
- Loading branch information
1 parent
7526081
commit 81c4da7
Showing
31 changed files
with
311 additions
and
224 deletions.
There are no files selected for viewing
15 changes: 5 additions & 10 deletions
15
packages/marko/src/core-tags/components/body-transformer.js
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,14 +1,9 @@ | ||
"use strict"; | ||
|
||
module.exports = function transform(el, context) { | ||
let componentGlobalsNode = context.createNodeForEl("component-globals"); | ||
el.prependChild(componentGlobalsNode); | ||
|
||
let initComponentsNode = context.createNodeForEl("init-components"); | ||
el.appendChild(initComponentsNode); | ||
|
||
// Make <await-reorderer> optional. Automatically insert it before the | ||
// body tag. | ||
let awaitReorderer = context.createNodeForEl("await-reorderer"); | ||
el.appendChild(awaitReorderer); | ||
if (context.outputType === "html") { | ||
el.appendChild(context.createNodeForEl("init-components")); | ||
el.appendChild(context.createNodeForEl("await-reorderer")); | ||
el.appendChild(context.createNodeForEl("_preferred-script-location")); | ||
} | ||
}; |
2 changes: 0 additions & 2 deletions
2
packages/marko/src/core-tags/components/component-globals-tag-browser.js
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
packages/marko/src/core-tags/components/component-globals-tag.js
This file was deleted.
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
25 changes: 25 additions & 0 deletions
25
packages/marko/src/core-tags/components/preferred-script-location-tag.js
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,25 @@ | ||
"use strict"; | ||
|
||
function forceScriptTagAtThisPoint(out) { | ||
const writer = out.writer; | ||
|
||
out.global.___isLastFlush = true; | ||
const htmlSoFar = writer.toString(); | ||
out.global.___isLastFlush = undefined; | ||
|
||
writer.clear(); | ||
writer.write(htmlSoFar); | ||
} | ||
|
||
module.exports = function render(input, out) { | ||
if (out.isSync() === true) { | ||
forceScriptTagAtThisPoint(out); | ||
} else { | ||
const asyncOut = out.beginAsync({ last: true, timeout: -1 }); | ||
out.onLast(function(next) { | ||
forceScriptTagAtThisPoint(asyncOut); | ||
asyncOut.end(); | ||
next(); | ||
}); | ||
} | ||
}; |
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
7 changes: 7 additions & 0 deletions
7
packages/marko/src/core-tags/migrate/component-globals-tag.js
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,7 @@ | ||
module.exports = function render(elNode, context) { | ||
context.deprecate( | ||
"The <component-globals> tag is deprecated. This functionality has been added to the '<init-components>' tag (which is automatically inserted at the end of the <body> tag), you can safely remove the '<component-globals>' tag." | ||
); | ||
|
||
elNode.detach(); | ||
}; |
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
Oops, something went wrong.