Commit 0b67b20f authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Polymer: update a couple node-based tools

* polymer-css-build: 0.0.9 -> 0.1.2
* vulcanize: 1.15.2 -> 1.15.4

Updating vulcanize allows us to trim our local patch.  I also renamed
patch_vulcanize.diff to chromium_vulcanize.patch as "chromium.patch"
seems like a more common file name for applying Chromium-specific
changes to third_party code.

BUG=598516
R=dpapad@chromium.org

Change-Id: Ib0b4234a1e497bad7ea930c1f14b841e723a60bc
Reviewed-on: https://chromium-review.googlesource.com/521883
Commit-Queue: Dan Beam <dbeam@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476552}
parent 38610ad5
diff --git a/lib/constants.js b/lib/constants.js
index 21e1380..b6a353a 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -13,6 +13,6 @@ module.exports = {
ABS_URL: /(^\/)|(^#)|(^[\w-\d]*:)/,
URL: /url\([^)]*\)/g,
URL_ATTR: ['href', 'src', 'action', 'style', 'assetpath'],
- URL_TEMPLATE: '{{.*}}|\\[\\[.*\\]\\]',
+ URL_TEMPLATE: '{{.*}}|\\[\\[.*\\]\\]|\\$i18n[^{]*{[^}]*}',
OLD_POLYMER: 'This version of vulcanize is not compatible with Polymer < 0.8. Please use vulcanize 0.7.x.'
};
1bbb442738b5c016c87d50cdf364ec6bcd779e6a 70eddb115269dddec7f911b3833fff3e37a6fbe8
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
"author": "dpapad@chromium.org", "author": "dpapad@chromium.org",
"dependencies": { "dependencies": {
"crisper": "2.0.2", "crisper": "2.0.2",
"eslint": "^3.19.0", "eslint": "3.19.0",
"polymer-css-build": "0.0.9", "polymer-css-build": "0.1.2",
"uglifyjs": "2.4.10", "uglifyjs": "2.4.10",
"vulcanize": "1.15.2" "vulcanize": "1.15.4"
} }
} }
diff --git a/bin/vulcanize b/bin/vulcanize
index 956b2bc..ad8b29d 100755
--- a/bin/vulcanize
+++ b/bin/vulcanize
@@ -35,6 +35,7 @@ var help = [
' --redirect <uri>|<path>: Takes an argument in the form of URI|PATH where url is a URI composed of a protocol, hostname, and path and PATH is a local filesystem path to replace the matched URI part with. Multiple redirects may be specified; the earliest ones have the highest priority.',
' --no-implicit-strip: DANGEROUS! Avoid stripping imports of the transitive dependencies of imports specified with `--exclude`. May result in duplicate javascript inlining.',
' --out-html <path>: If specified, output will be written to <path> instead of stdout.',
+ ' --out-request-list <path>: Writes a list of request URLs required to vulcanize <html file> to <path> on success.',
'Examples:',
' The command',
'',
@@ -82,7 +83,8 @@ var args = nopt(
'no-implicit-strip': Boolean,
'inline-scripts': Boolean,
'inline-css': Boolean,
- 'out-html': String
+ 'out-html': String,
+ 'out-request-list': String
},
{
'h': ['--help'],
@@ -126,15 +128,23 @@ args.implicitStrip = !args['no-implicit-strip'];
args.inlineScripts = args['inline-scripts'];
args.inlineCss = args['inline-css'];
-(new vulcan(args)).process(target, function(err, content) {
+var vulcanize = new vulcan(args);
+vulcanize.process(target, function(err, content) {
if (err) {
process.stderr.write(require('util').inspect(err));
process.exit(1);
}
+
+ if (args['out-request-list']) {
+ var urls = Object.keys(vulcanize.loader.requests).filter(function(request) {
+ // Filter out excluded URLs.
+ return !vulcanize.isExcludedHref(request);
+ });
+ fs.writeFileSync(args['out-request-list'], urls.join('\n') + '\n');
+ }
+
if (args['out-html']) {
- var fd = fs.openSync(args['out-html'], 'w');
- fs.writeSync(fd, content + "\n");
- fs.closeSync(fd);
+ fs.writeFileSync(args['out-html'], content + '\n');
} else {
process.stdout.write(content);
}
diff --git a/lib/constants.js b/lib/constants.js
index 21e1380..b6a353a 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -13,6 +13,6 @@ module.exports = {
ABS_URL: /(^\/)|(^#)|(^[\w-\d]*:)/,
URL: /url\([^)]*\)/g,
URL_ATTR: ['href', 'src', 'action', 'style', 'assetpath'],
- URL_TEMPLATE: '{{.*}}|\\[\\[.*\\]\\]',
+ URL_TEMPLATE: '{{.*}}|\\[\\[.*\\]\\]|\\$i18n[^{]*{[^}]*}',
OLD_POLYMER: 'This version of vulcanize is not compatible with Polymer < 0.8. Please use vulcanize 0.7.x.'
};
diff --git a/lib/vulcan.js b/lib/vulcan.js
index 5aff456..2540dc1 100644
--- a/lib/vulcan.js
+++ b/lib/vulcan.js
@@ -414,19 +414,21 @@ Vulcan.prototype = {
},
getImplicitExcludes: function getImplicitExcludes(excludes) {
- // Build a loader that doesn't have to stop at our excludes, since we need them.
+ // Build a loader that doesn't have to stop at our HTML excludes, since we
+ // need them. JS excludes should still be excluded.
var loader = buildLoader({
abspath: this.abspath,
fsResolver: this.fsResolver,
- redirects: this.redirects
+ redirects: this.redirects,
+ excludes: excludes.filter(function(e) { return e.match(/.js$/i); })
});
var analyzer = new hyd.Analyzer(true, loader);
var analyzedExcludes = [];
excludes.forEach(function(exclude) {
- if (exclude.match(/.js$/)) {
+ if (exclude.match(/.js$/i)) {
return;
}
- if (exclude.match(/.css$/)) {
+ if (exclude.match(/.css$/i)) {
return;
}
if (exclude.slice(-1) === '/') {
...@@ -18,8 +18,8 @@ rm -rf node_modules ...@@ -18,8 +18,8 @@ rm -rf node_modules
npm install --no-bin-links --only=prod npm install --no-bin-links --only=prod
# Apply local patch to vulacanize. # Apply local patch to vulcanize.
patch -d node_modules/vulcanize/ -p1 < patch_vulcanize.diff patch -d node_modules/vulcanize/ -p1 < chromium_vulcanize.patch
rsync -c --delete -r -q --exclude-from="npm_exclude.txt" \ rsync -c --delete -r -q --exclude-from="npm_exclude.txt" \
--prune-empty-dirs "node_modules/" "node_modules_filtered/" --prune-empty-dirs "node_modules/" "node_modules_filtered/"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment