From c9b31bbeff11d1b57b9057a01b72b2b8d708c4d7 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 12 Sep 2018 14:50:00 -0700 Subject: [PATCH 1/9] Drop esm module for a bundle of shadycss --- .eslintignore | 2 +- .gitignore | 8 ++------ .npmignore | 8 -------- dev/shadycss.js | 28 ++++++++++++++++++++++++++++ lib/shadycss-entrypoint.js | 8 +------- package.json | 21 ++++++++++++++++----- rollup.config.js | 25 +++++++++++++++++++++++++ 7 files changed, 73 insertions(+), 27 deletions(-) delete mode 100644 .npmignore create mode 100644 dev/shadycss.js create mode 100644 rollup.config.js diff --git a/.eslintignore b/.eslintignore index 35d0031..32372b6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1 @@ -lib/polymer-styling.js +lib/bundled-shadycss.js \ No newline at end of file diff --git a/.gitignore b/.gitignore index 96e7cab..495779f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ -bower_components -node_modules -test/shadow -test/shady -test/webcomponentsjs .vscode -example +node_modules tests/generated +lib/bundled-shadycss.js \ No newline at end of file diff --git a/.npmignore b/.npmignore deleted file mode 100644 index bcdcf5a..0000000 --- a/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -bower_components -node_modules -test/shadow -test/shady -test/webcomponentsjs -.vscode -example -polymer diff --git a/dev/shadycss.js b/dev/shadycss.js new file mode 100644 index 0000000..b9e104b --- /dev/null +++ b/dev/shadycss.js @@ -0,0 +1,28 @@ +/**! + * @license + * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +/** + * @fileoverview + * + * A library that bundles all the parts of ShadyCSS that polymer-css-build + * needs. + */ + +import * as StyleUtil from '@webcomponents/shadycss/src/style-util.js'; +import * as CssParse from '@webcomponents/shadycss/src/css-parse.js'; + +export {default as StyleTransformer} from '@webcomponents/shadycss/src/style-transformer.js'; +export {default as ApplyShim} from '@webcomponents/shadycss/src/apply-shim.js'; +export {scopingAttribute as ShadyUnscopedAttribute} from '@webcomponents/shadycss/src/unscoped-style-handler.js'; + +export {StyleUtil, CssParse}; \ No newline at end of file diff --git a/lib/shadycss-entrypoint.js b/lib/shadycss-entrypoint.js index aaf5322..405cabc 100644 --- a/lib/shadycss-entrypoint.js +++ b/lib/shadycss-entrypoint.js @@ -12,9 +12,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN * Load ShadyCSS */ function loadShadyCSS(nativeShadow) { - /* enable ES Modules from @webcomponents/shadycss */ - require = require('esm')(module); //eslint-disable-line no-global-assign - /** * Boilerplate for using ShadyCSS in a Node context */ @@ -27,10 +24,7 @@ function loadShadyCSS(nativeShadow) { } }; - const StyleTransformer = require('@webcomponents/shadycss/src/style-transformer.js').default; - const StyleUtil = require('@webcomponents/shadycss/src/style-util.js'); - const ApplyShim = require('@webcomponents/shadycss/src/apply-shim.js').default; - const CssParse = require('@webcomponents/shadycss/src/css-parse.js'); + const {StyleTransformer, StyleUtil, ApplyShim, CssParse} = require('./bundled-shadycss.js'); /** * Apply Shim uses a dynamically create DOM element diff --git a/package.json b/package.json index 069af13..5a4afbb 100644 --- a/package.json +++ b/package.json @@ -7,26 +7,28 @@ "polymer-css-build": "bin/polymer-css-build" }, "scripts": { - "lint": "eslint **/*.js", + "lint": "eslintG **/*.js", "prepare-tests": "./tests/prepare-tests.sh", - "test": "npm run lint && npm run prepare-tests && wct" + "test": "npm run lint && npm run prepare-tests && wct", + "bundle": "rollup -c rollup.config.js" }, "author": "The Polymer Authors", "license": "BSD-3-Clause", "devDependencies": { + "@webcomponents/shadycss": "^1.5.0", "babel-eslint": "^8.2.6", "bower": "^1.8.4", "eslint": "^4.19.1", "eslint-plugin-html": "^4.0.5", + "rollup": "^0.65.2", + "rollup-plugin-node-resolve": "^3.4.0", "wct-browser-legacy": "^1.0.1", "web-component-tester": "^6.7.1" }, "dependencies": { - "@webcomponents/shadycss": "^1.3.5", "command-line-args": "^5.0.2", "command-line-usage": "^5.0.5", "dom5": "^3.0.1", - "esm": "^3.0.72", "polymer-analyzer": "2.7 - 3" }, "directories": { @@ -43,5 +45,14 @@ "bugs": { "url": "https://github.com/PolymerLabs/polymer-css-build/issues" }, - "homepage": "https://github.com/PolymerLabs/polymer-css-build#readme" + "homepage": "https://github.com/PolymerLabs/polymer-css-build#readme", + "files": [ + "package.json", + "index.js", + "README", + "CHANGELOG.md", + "LICENSE", + "bin/*", + "lib/*" + ] } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..5e3f0e3 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,25 @@ +/** + * @license + * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */ +import resolve from 'rollup-plugin-node-resolve'; + +export default { + input: 'dev/shadycss.js', + output: { + file: 'lib/bundled-shadycss.js', + format: 'cjs' + }, + plugins: [ + resolve() + ] +}; \ No newline at end of file From ce2f43f12ac24887d60d9baf2aebcc0f02968af0 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 12 Sep 2018 14:51:49 -0700 Subject: [PATCH 2/9] 0.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a4afbb..8b70f9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polymer-css-build", - "version": "0.3.0", + "version": "0.3.1", "description": "Build tool for Polymer css", "main": "index.js", "bin": { From 18c467028102c8225348b93d62166c4328f318c5 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 12 Sep 2018 15:31:21 -0700 Subject: [PATCH 3/9] fix mistake in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b70f9c..0cc7ebf 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "polymer-css-build": "bin/polymer-css-build" }, "scripts": { - "lint": "eslintG **/*.js", + "lint": "eslint **/*.js", "prepare-tests": "./tests/prepare-tests.sh", "test": "npm run lint && npm run prepare-tests && wct", "bundle": "rollup -c rollup.config.js" From ea7aaff81c4f84a28ebfa011b1e706a82a925453 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 12 Sep 2018 15:40:12 -0700 Subject: [PATCH 4/9] travis has to bundle itself --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 623a506..c9a7356 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ addons: firefox: latest chrome: stable script: +- npm run bundle - echo "polymer-analyzer 2.7" - npm install --no-save polymer-analyzer@2.7 - xvfb-run npm test -- -l chrome From 543031212a8939296dc77749f99e75d78bf870a1 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 12 Sep 2018 17:16:41 -0700 Subject: [PATCH 5/9] Don't mark templates in polymer v1 builds Backport of ba3df1bf44a78cd24f82b6be7673dcf020104c6d --- index.js | 8 +++++--- tests/app/index.html | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index fd015e5..2258190 100644 --- a/index.js +++ b/index.js @@ -197,14 +197,16 @@ function addClass(node, className) { dom5.setAttribute(node, 'class', classList.join(' ')); } -function markElement(domModule, scope, useNativeShadow) { +function markElement(domModule, scope, useNativeShadow, markTemplate = true) { const buildType = useNativeShadow ? 'shadow' : 'shady'; // apply scoping to dom-module dom5.setAttribute(domModule, 'css-build', buildType); // apply scoping to template const template = dom5.query(domModule, pred.hasTagName('template')); if (template) { - dom5.setAttribute(template, 'css-build', buildType); + if (markTemplate) { + dom5.setAttribute(template, 'css-build', buildType); + } // mark elements' subtree under shady build if (buildType === 'shady' && scope) { const elements = dom5.queryAll(template, notStyleMatch, undefined, dom5.childNodesIncludeTemplate); @@ -319,7 +321,7 @@ async function polymerCssBuild(paths, options = {}) { const el = getAstNode(domModule); domModuleCache[scope] = el; setNodeFileLocation(el, domModule); - markElement(el, scope, nativeShadow); + markElement(el, scope, nativeShadow, polymerVersion > 1); const styles = getAndFixDomModuleStyles(el); styles.forEach((s) => { scopeMap.set(s, scope); diff --git a/tests/app/index.html b/tests/app/index.html index c4f2435..8e7c59f 100644 --- a/tests/app/index.html +++ b/tests/app/index.html @@ -113,7 +113,9 @@ const dm = Polymer.DomModule.import('x-app'); assert(dm.hasAttribute('css-build'), 'dom-module should have css-build attribute'); const template = dm.querySelector('template'); - assert(template.hasAttribute('css-build'), 'dom-module template should have css-build attribute'); + if (Polymer.Element) { + assert(template.hasAttribute('css-build'), 'dom-module template should have css-build attribute'); + } }); }); \ No newline at end of file From ee6b4a85d0246a75df2044844c62cb35b3b10bd3 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 12 Sep 2018 17:23:40 -0700 Subject: [PATCH 6/9] 0.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0cc7ebf..18fa19f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polymer-css-build", - "version": "0.3.1", + "version": "0.3.2", "description": "Build tool for Polymer css", "main": "index.js", "bin": { From 978d3ac0436507161507e59b1cd546d7e64edb3c Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Fri, 28 Sep 2018 15:57:39 -0700 Subject: [PATCH 7/9] add prepare step --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 18fa19f..5e0cdd8 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "lint": "eslint **/*.js", "prepare-tests": "./tests/prepare-tests.sh", "test": "npm run lint && npm run prepare-tests && wct", - "bundle": "rollup -c rollup.config.js" + "bundle": "rollup -c rollup.config.js", + "prepare": "npm run bundle" }, "author": "The Polymer Authors", "license": "BSD-3-Clause", From 4f539b35d4981eedc5f8c7075d475764f35e5eb0 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Fri, 28 Sep 2018 15:59:54 -0700 Subject: [PATCH 8/9] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8750a95..9fac6f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ # Change Log +## [0.3.3] - 2018-09-28 +* Rebuild shadycss bundle with changes from https://github.com/webcomponents/shadycss/pull/215 + +## [0.3.2] - 2018-09-12 +* Don't mark templates in polymer v1 builds + +## [0.3.1] - 2018-09-12 +* Drop `esm` module for bundling with `rollup` ## [0.3.0] - 2018-08-10 * Upgrade to using @webcomponents/shadydom for Polymer v2 support From c32c64eff2cfb11790bc9a334541f501e4ef1c86 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Fri, 28 Sep 2018 16:00:22 -0700 Subject: [PATCH 9/9] 0.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e0cdd8..daf9b32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polymer-css-build", - "version": "0.3.2", + "version": "0.3.3", "description": "Build tool for Polymer css", "main": "index.js", "bin": {