Tools: Prevent from adding `html`, `body`, `head` tags to the rejoined file.

Created on 8 Apr 2017  路  12Comments  路  Source: Polymer/tools

require('polymer-build').HtmlSplitter adds html, head, body tags, which causes issues for my app.

Example:
A file
<h1>Hello</h1>
becomes
<html><head></head><body><h1>Hello</h1></body></html>

How to prevent this behavior ?

build Critical Available Bug

All 12 comments

I think your tool for splitting HTML, then using conditionals to target the specific parts is amazing, and shouldn't be limited to webcomponents structures only.
Personally I would like to use it for html files that contain inline scripts (<script> tags), and apply custom transpilation and minification on these tags.
It could be further developed for recognizing custom tags/attributes, and ability to target specific custom parts in the documents.
Thanks

The fix in code is for us to notice pars5.ASTNodes without locations. These are nodes that were hallucinated by the HTML5 parsing algorithm. ParsedHtmlDocument#stringify in the analyzer handles this, might be able to use that. Or could just copy removeFakeNodes here (though note that it mutates the document, so only use it on a non-shared document, or use the clone library): https://github.com/Polymer/polymer-analyzer/blob/master/src/html/html-document.ts#L205-L217

@usergenic I wonder if the releases in

are the same. Because when installing through NPM repository it installs the version v1.1.0 which matches the fix, but in node_modules the file doesn't have the merged code.
Releases are not synchronous ?
Thanks for the fix.

Reopening to track investigation

The #185 was merged after the v1.1.0. It's on master.

Now its working. Before I needed to npm install directly from github:polymer/polymer-build, and them build the module manually (npm install; npm run build).

@abdonrd I'm sorry for closing it too early. I did a clean npm install (where package.json has "polymer-build": "^1.1.0"), and the versions aren't the same between NPM repo and Github (although both refer to 1.1.0). I will let you close the issue after verifying.

The only way I got it to work is installing it directly from Github:

  • npm install --save github:polymer/polymer-build
  • cd ./node_modules/polymer-build; npm install; npm run build;

That is because the #185 was merged after the v1.1.0.
You have to wait for the Polymer Team release a new version.

Oh, now I see. The master branch is different from the latest release (v1.1.0). Thanks

Any idea of when the new release is going to be published to npm?

@s2tephen hoping to get a release of build out after https://github.com/Polymer/polymer-build/pull/189 lands, preferably by/on Monday, Apr 24.

polymer-build 1.2.0 published 馃帀

Was this page helpful?
0 / 5 - 0 ratings