From c9b31bbeff11d1b57b9057a01b72b2b8d708c4d7 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 12 Sep 2018 14:50:00 -0700 Subject: [PATCH] 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