From f28cfcf7d1e7204e4cfb0e3f0aed49b7021721ff Mon Sep 17 00:00:00 2001 From: nikek Date: Fri, 20 Mar 2020 16:24:35 +0100 Subject: [PATCH 01/19] Add rollup for plugin build --- .gitignore | 1 + .../cli/@types/rollup-plugin-image-files.d.ts | 1 + packages/cli/package.json | 11 +- packages/cli/src/commands/plugin/assets.d.ts | 4 + packages/cli/src/commands/plugin/build.ts | 50 +-- .../cli/src/commands/plugin/rollup.config.ts | 43 +++ packages/cli/src/index.ts | 4 +- .../templates/default-plugin/package.json.hbs | 19 +- .../templates/default-plugin/tsconfig.json | 5 +- plugins/home-page/package.json | 26 +- plugins/home-page/tsconfig.json | 5 +- plugins/welcome/package.json | 21 +- plugins/welcome/tsconfig.json | 5 +- yarn.lock | 357 +++++++++++++++++- 14 files changed, 478 insertions(+), 74 deletions(-) create mode 100644 packages/cli/@types/rollup-plugin-image-files.d.ts create mode 100644 packages/cli/src/commands/plugin/rollup.config.ts diff --git a/.gitignore b/.gitignore index ff5491eba7..f124971429 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea/ .DS_Store .vscode/ +.vsls.json # @spotify/web-script build output cjs/ diff --git a/packages/cli/@types/rollup-plugin-image-files.d.ts b/packages/cli/@types/rollup-plugin-image-files.d.ts new file mode 100644 index 0000000000..ba8ac05645 --- /dev/null +++ b/packages/cli/@types/rollup-plugin-image-files.d.ts @@ -0,0 +1 @@ +declare module 'rollup-plugin-image-files'; diff --git a/packages/cli/package.json b/packages/cli/package.json index 005fcf01ad..db268ebc25 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -33,6 +33,8 @@ "@types/react-dev-utils": "^9.0.4", "@types/recursive-readdir": "^2.2.0", "@types/tar": "^4.0.3", + "@types/rollup-plugin-peer-deps-external": "2.2.0", + "@types/rollup-plugin-postcss": "2.0.0", "@types/webpack": "^4.41.7", "@types/webpack-dev-server": "^3.10.0", "del": "^5.1.0", @@ -46,6 +48,8 @@ "dependencies": { "@lerna/package-graph": "^3.18.5", "@lerna/project": "^3.18.0", + "@rollup/plugin-commonjs": "^11.0.2", + "@rollup/plugin-node-resolve": "^7.1.1", "@spotify/web-scripts": "^6.0.0", "chokidar": "^3.3.1", "commander": "^4.1.1", @@ -60,6 +64,11 @@ "react-scripts": "^3.4.0", "recursive-readdir": "^2.2.2", "replace-in-file": "^5.0.2", + "rollup": "^2.1.0", + "rollup-plugin-image-files": "^1.4.2", + "rollup-plugin-peer-deps-external": "^2.2.2", + "rollup-plugin-postcss": "^2.5.0", + "rollup-plugin-typescript2": "^0.26.0", "ts-loader": "^6.2.1", "webpack": "^4.41.6", "webpack-dev-server": "^3.10.3" @@ -72,7 +81,7 @@ ], "nodemonConfig": { "watch": "./src", - "exec": "ts-node", + "exec": "ts-node ./src", "ext": "ts" } } diff --git a/packages/cli/src/commands/plugin/assets.d.ts b/packages/cli/src/commands/plugin/assets.d.ts index 54523e926b..34bb6acb70 100644 --- a/packages/cli/src/commands/plugin/assets.d.ts +++ b/packages/cli/src/commands/plugin/assets.d.ts @@ -94,3 +94,7 @@ declare module '*.module.sass' { const classes: { readonly [key: string]: string }; export default classes; } + +declare module 'rollup-plugin-image-files' { + export default function image(): any; +} diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 4c2113eb2a..1cbfd72413 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -14,43 +14,17 @@ * limitations under the License. */ -import { Command } from 'commander'; -import fs from 'fs-extra'; -import path from 'path'; -import recursive from 'recursive-readdir'; -import { run } from '../../helpers/run'; +const rollup = require('rollup'); // "import" is not working for some reason... +import rollupConfig from './rollup.config'; -const copyStaticAssets = async () => { - const pluginRoot = fs.realpathSync(process.cwd()); - const source = path.resolve(pluginRoot, 'src'); - const destination = path.resolve(pluginRoot, 'dist', 'cjs'); - const assetFiles = await recursive(source, [ - '**/*.tsx', - '**/*.ts', - '**/*.js', - ]); - assetFiles.forEach(file => { - const fileToBeCopied = file.replace(source, destination); - const dirForFileToBeCopied = path.dirname(fileToBeCopied); - fs.ensureDirSync(dirForFileToBeCopied); - fs.copyFileSync(file, file.replace(source, destination).toString()); - }); -}; - -export default async (cmd: Command) => { - const args = [ - '--outDir', - 'dist/cjs', - '--noEmit', - 'false', - '--module', - 'CommonJS', - ]; - - if (cmd.watch) { - args.push('--watch'); - } - - await copyStaticAssets(); - await run('tsc', args); +export default async () => { + const inputOptions = { + input: rollupConfig.input, + plugins: rollupConfig.plugins, + }; + const outputOptions = rollupConfig.output; + + const bundle = await rollup.rollup(inputOptions); + await bundle.generate(outputOptions); + await bundle.write(outputOptions); }; diff --git a/packages/cli/src/commands/plugin/rollup.config.ts b/packages/cli/src/commands/plugin/rollup.config.ts new file mode 100644 index 0000000000..85287ae752 --- /dev/null +++ b/packages/cli/src/commands/plugin/rollup.config.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import peerDepsExternal from 'rollup-plugin-peer-deps-external'; +import typescript from 'rollup-plugin-typescript2'; // @rollup/plugin-typescript +import commonjs from '@rollup/plugin-commonjs'; +import resolve from '@rollup/plugin-node-resolve'; +import postcss from 'rollup-plugin-postcss'; +import image from 'rollup-plugin-image-files'; + +export default { + input: 'src/index.ts', + output: { + file: 'build/index.esm.js', + format: 'esm', + sourcemap: true, + }, + + plugins: [ + peerDepsExternal(), + resolve(), + commonjs({ + include: ['node_modules/**', '../../node_modules/**'], + exclude: ['**/*.stories.js'], + }), + postcss(), + image(), + typescript(), + ], +}; diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 31cc0f95ce..9687e100d1 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -143,4 +143,6 @@ process.on('unhandledRejection', rejection => { }); main(process.argv); -// main([process.argv[0], process.argv[1], '--version']); +// process.chdir('../../plugins/welcome'); +// console.log(`DEBUG: ${process.cwd()}`); +// main([process.argv[0], process.argv[1], 'plugin:build']); diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index c7220a8fd3..3e7e546170 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -1,8 +1,8 @@ { "name": "@backstage/plugin-{{id}}", "version": "{{version}}", - "main": "dist/cjs/index.js", - "types": "dist/cjs/index.d.ts", + "main": "build/index.esm.js", + "types": "build/index.d.ts", "license": "Apache-2.0", "private": true, "scripts": { @@ -12,11 +12,20 @@ }, "devDependencies": { "@backstage/cli": "^{{version}}", + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^7.1.2", + "@types/jest": "^24.0.0", + "@types/node": "^12.0.0", "@types/testing-library__jest-dom": "5.0.2", "jest-fetch-mock": "^3.0.3" }, - "dependencies": { - "@backstage/core": "^{{version}}", - "@material-ui/lab": "4.0.0-alpha.45" + "peerDependencies": { + "@backstage/core": "^0.1.0", + "@material-ui/core": "^4.9.1", + "@material-ui/icons": "^4.9.1", + "@material-ui/lab": "4.0.0-alpha.45", + "react": "16.13.1", + "react-dom": "16.13.1" } } diff --git a/packages/cli/templates/default-plugin/tsconfig.json b/packages/cli/templates/default-plugin/tsconfig.json index 596e2cf729..4721441081 100644 --- a/packages/cli/templates/default-plugin/tsconfig.json +++ b/packages/cli/templates/default-plugin/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "../../tsconfig.json", - "include": ["src"] + "include": ["src"], + "compilerOptions": { + "module": "es6" + } } diff --git a/plugins/home-page/package.json b/plugins/home-page/package.json index 91e3da417f..cd755627bd 100644 --- a/plugins/home-page/package.json +++ b/plugins/home-page/package.json @@ -1,9 +1,15 @@ { "name": "@backstage/plugin-home-page", "version": "0.1.1-alpha.0", - "main": "dist/cjs/index.js", - "types": "dist/cjs/index.d.ts", - "private": true, + "module": "build/index.esm.js", + "types": "build/index.d.ts", + "license": "Apache-2.0", + "private": false, + "scripts": { + "build": "backstage-cli build-cache -- backstage-cli plugin:build", + "lint": "backstage-cli lint", + "test": "backstage-cli test" + }, "devDependencies": { "@backstage/cli": "^0.1.1-alpha.0", "@backstage/core": "^0.1.1-alpha.0", @@ -18,10 +24,12 @@ "react": "^16.12.0", "react-dom": "^16.12.0" }, - "scripts": { - "build": "backstage-cli build-cache -- backstage-cli plugin:build", - "lint": "backstage-cli lint", - "test": "backstage-cli test" - }, - "license": "Apache-2.0" + "peerDependencies": { + "@material-ui/core": "^4.9.1", + "@material-ui/icons": "^4.9.1", + "@material-ui/lab": "4.0.0-alpha.45", + "@backstage/core": "^0.1.0", + "react": "16.13.1", + "react-dom": "16.13.1" + } } diff --git a/plugins/home-page/tsconfig.json b/plugins/home-page/tsconfig.json index 596e2cf729..4721441081 100644 --- a/plugins/home-page/tsconfig.json +++ b/plugins/home-page/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "../../tsconfig.json", - "include": ["src"] + "include": ["src"], + "compilerOptions": { + "module": "es6" + } } diff --git a/plugins/welcome/package.json b/plugins/welcome/package.json index e1672b4c40..97a2a08772 100644 --- a/plugins/welcome/package.json +++ b/plugins/welcome/package.json @@ -1,10 +1,10 @@ { "name": "@backstage/plugin-welcome", "version": "0.1.1-alpha.0", - "main": "dist/cjs/index.js", - "types": "dist/cjs/index.d.ts", + "module": "build/index.esm.js", + "types": "build/index.d.ts", "license": "Apache-2.0", - "private": true, + "private": false, "scripts": { "build": "backstage-cli build-cache -- backstage-cli plugin:build", "lint": "backstage-cli lint", @@ -13,9 +13,20 @@ "devDependencies": { "@backstage/cli": "^0.1.1-alpha.0", "@backstage/core": "^0.1.1-alpha.0", + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^7.1.2", + "@types/jest": "^24.0.0", + "@types/node": "^12.0.0", "@types/testing-library__jest-dom": "5.0.2" }, - "dependencies": { - "@material-ui/lab": "4.0.0-alpha.45" + "peerDependencies": { + "@material-ui/core": "^4.9.1", + "@material-ui/icons": "^4.9.1", + "@material-ui/lab": "4.0.0-alpha.45", + "@backstage/core": "^0.1.0", + "react": "16.13.1", + "react-dom": "16.13.1", + "react-router-dom": "5.1.2" } } diff --git a/plugins/welcome/tsconfig.json b/plugins/welcome/tsconfig.json index 596e2cf729..4721441081 100644 --- a/plugins/welcome/tsconfig.json +++ b/plugins/welcome/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "../../tsconfig.json", - "include": ["src"] + "include": ["src"], + "compilerOptions": { + "module": "es6" + } } diff --git a/yarn.lock b/yarn.lock index d9bf6eaadf..b844a4952f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2648,6 +2648,35 @@ prop-types "^15.6.1" react-lifecycles-compat "^3.0.4" +"@rollup/plugin-commonjs@^11.0.2": + version "11.0.2" + resolved "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.2.tgz#837cc6950752327cb90177b608f0928a4e60b582" + integrity sha512-MPYGZr0qdbV5zZj8/2AuomVpnRVXRU5XKXb3HVniwRoRCreGlf5kOE081isNWeiLIi6IYkwTX9zE0/c7V8g81g== + dependencies: + "@rollup/pluginutils" "^3.0.0" + estree-walker "^1.0.1" + is-reference "^1.1.2" + magic-string "^0.25.2" + resolve "^1.11.0" + +"@rollup/plugin-node-resolve@^7.1.1": + version "7.1.1" + resolved "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.1.tgz#8c6e59c4b28baf9d223028d0e450e06a485bb2b7" + integrity sha512-14ddhD7TnemeHE97a4rLOhobfYvUVcaYuqTnL8Ti7Jxi9V9Jr5LY7Gko4HZ5k4h4vqQM0gBQt6tsp9xXW94WPA== + dependencies: + "@rollup/pluginutils" "^3.0.6" + "@types/resolve" "0.0.8" + builtin-modules "^3.1.0" + is-module "^1.0.0" + resolve "^1.14.2" + +"@rollup/pluginutils@^3.0.0", "@rollup/pluginutils@^3.0.6": + version "3.0.8" + resolved "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.8.tgz#4e94d128d94b90699e517ef045422960d18c8fde" + integrity sha512-rYGeAc4sxcZ+kPG/Tw4/fwJODC3IXHYDH4qusdN/b6aLw5LPUbzpecYbEJh4sVQGPFJxd2dBU4kc1H3oy9/bnw== + dependencies: + estree-walker "^1.0.1" + "@samverschueren/stream-to-observable@^0.3.0": version "0.3.0" resolved "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f" @@ -3432,6 +3461,13 @@ dependencies: "@types/node" "*" +"@types/cssnano@*": + version "4.0.0" + resolved "https://registry.npmjs.org/@types/cssnano/-/cssnano-4.0.0.tgz#f1bb29d6d0813861a3d87e02946b2988d0110d4e" + integrity sha512-BC/2ibKZfPIaBLBNzkitdW1IvvX/LKW6/QXGc4Su/tAJ7mQ3f2CKBuGCCKaqGAnoKwzfuC7G/recpkARwdOwuA== + dependencies: + postcss "5 - 7" + "@types/debug@^4.1.2": version "4.1.5" resolved "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd" @@ -3455,6 +3491,11 @@ resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.44.tgz#980cc5a29a3ef3bea6ff1f7d021047d7ea575e21" integrity sha512-iaIVzr+w2ZJ5HkidlZ3EJM8VTZb2MJLCjw3V+505yVts0gRC4UMvjw0d1HPtGqI/HQC/KdsYtayfzl+AXY2R8g== +"@types/estree@0.0.39": + version "0.0.39" + resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" + integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== + "@types/events@*": version "3.0.0" resolved "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" @@ -3750,11 +3791,35 @@ resolved "https://registry.npmjs.org/@types/relateurl/-/relateurl-0.2.28.tgz#6bda7db8653fa62643f5ee69e9f69c11a392e3a6" integrity sha1-a9p9uGU/piZD9e5p6facEaOS46Y= +"@types/resolve@0.0.8": + version "0.0.8" + resolved "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" + integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== + dependencies: + "@types/node" "*" + "@types/retry@^0.12.0": version "0.12.0" resolved "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d" integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA== +"@types/rollup-plugin-peer-deps-external@2.2.0": + version "2.2.0" + resolved "https://registry.npmjs.org/@types/rollup-plugin-peer-deps-external/-/rollup-plugin-peer-deps-external-2.2.0.tgz#eae7d8b9d27fa037f5bcaded24e389f85b81973c" + integrity sha512-BiztED+KYJPBI3ihLSOuuZSzy836WAOpC9UrMtDqk3+VeByR8A5pJJ9pCVnq/dfB4wyCeiFL+FlyJnqZuP3pxg== + dependencies: + "@types/node" "*" + rollup "^0.63.4" + +"@types/rollup-plugin-postcss@2.0.0": + version "2.0.0" + resolved "https://registry.npmjs.org/@types/rollup-plugin-postcss/-/rollup-plugin-postcss-2.0.0.tgz#b1bcc686c7dbe441f2fcfb47cac01acc508f46c0" + integrity sha512-lw4LvCcWpQ/Yomb9bxT69uAN5ZfW6nhL9itEu3z0IzsNNqKalwIDo7pEK8jxoiHQmcPaYzayAfo4M1JT/h8crw== + dependencies: + "@types/cssnano" "*" + "@types/node" "*" + rollup "^0.63.4" + "@types/serve-static@*": version "1.13.3" resolved "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.3.tgz#eb7e1c41c4468272557e897e9171ded5e2ded9d1" @@ -5481,6 +5546,11 @@ buffer@^4.3.0: ieee754 "^1.1.4" isarray "^1.0.0" +builtin-modules@^3.1.0: + version "3.1.0" + resolved "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484" + integrity sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw== + builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" @@ -6259,6 +6329,13 @@ concat-stream@^2.0.0: readable-stream "^3.0.2" typedarray "^0.0.6" +concat-with-sourcemaps@^1.0.5: + version "1.1.0" + resolved "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e" + integrity sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg== + dependencies: + source-map "^0.6.1" + config-chain@^1.1.11, config-chain@^1.1.12: version "1.1.12" resolved "https://registry.npmjs.org/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa" @@ -6709,6 +6786,18 @@ css-loader@3.4.2, css-loader@^3.0.0: postcss-value-parser "^4.0.2" schema-utils "^2.6.0" +css-modules-loader-core@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/css-modules-loader-core/-/css-modules-loader-core-1.1.0.tgz#5908668294a1becd261ae0a4ce21b0b551f21d16" + integrity sha1-WQhmgpShvs0mGuCkziGwtVHyHRY= + dependencies: + icss-replace-symbols "1.1.0" + postcss "6.0.1" + postcss-modules-extract-imports "1.1.0" + postcss-modules-local-by-default "1.2.0" + postcss-modules-scope "1.1.0" + postcss-modules-values "1.3.0" + css-prefers-color-scheme@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/css-prefers-color-scheme/-/css-prefers-color-scheme-3.1.1.tgz#6f830a2714199d4f0d0d0bb8a27916ed65cff1f4" @@ -6741,6 +6830,15 @@ css-select@^2.0.0: domutils "^1.7.0" nth-check "^1.0.2" +css-selector-tokenizer@^0.7.0: + version "0.7.2" + resolved "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.7.2.tgz#11e5e27c9a48d90284f22d45061c303d7a25ad87" + integrity sha512-yj856NGuAymN6r8bn8/Jl46pR+OC3eEvAhfGYDUe7YPtTPAYrSSw4oAniZ9Y8T5B92hjhwTBLUen0/vKPxf6pw== + dependencies: + cssesc "^3.0.0" + fastparse "^1.1.2" + regexpu-core "^4.6.0" + css-tree@1.0.0-alpha.37: version "1.0.0-alpha.37" resolved "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz#98bebd62c4c1d9f960ec340cf9f7522e30709a22" @@ -6863,7 +6961,7 @@ cssnano-util-same-parent@^4.0.0: resolved "https://registry.npmjs.org/cssnano-util-same-parent/-/cssnano-util-same-parent-4.0.1.tgz#574082fb2859d2db433855835d9a8456ea18bbf3" integrity sha512-WcKx5OY+KoSIAxBW6UBBRay1U6vkYheCdjyVNDm85zt5K9mHoGOfsOsqIszfAqrQQFIIKgjh2+FDgIj/zsl21Q== -cssnano@^4.1.10: +cssnano@^4.1.10, cssnano@^4.1.8: version "4.1.10" resolved "https://registry.npmjs.org/cssnano/-/cssnano-4.1.10.tgz#0ac41f0b13d13d465487e111b778d42da631b8b2" integrity sha512-5wny+F6H4/8RgNlaqab4ktc3e0/blKutmq8yNlBFXA//nSFFAqAngjNVRzUvCgYROULmZZUoosL/KSoZo5aUaQ== @@ -8064,6 +8162,16 @@ estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: resolved "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== +estree-walker@^0.6.0, estree-walker@^0.6.1: + version "0.6.1" + resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" + integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== + +estree-walker@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" + integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== + esutils@^2.0.2: version "2.0.3" resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -8405,6 +8513,11 @@ fastest-stable-stringify@^1.0.1: resolved "https://registry.npmjs.org/fastest-stable-stringify/-/fastest-stable-stringify-1.0.1.tgz#9122d406d4c9d98bea644a6b6853d5874b87b028" integrity sha1-kSLUBtTJ2YvqZEpraFPVh0uHsCg= +fastparse@^1.1.2: + version "1.1.2" + resolved "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz#91728c5a5942eced8531283c79441ee4122c35a9" + integrity sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ== + fastq@^1.6.0: version "1.6.1" resolved "https://registry.npmjs.org/fastq/-/fastq-1.6.1.tgz#4570c74f2ded173e71cf0beb08ac70bb85826791" @@ -8951,6 +9064,13 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" +generic-names@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/generic-names/-/generic-names-2.0.1.tgz#f8a378ead2ccaa7a34f0317b05554832ae41b872" + integrity sha512-kPCHWa1m9wGG/OwQpeweTwM/PYiQLrUIxXbt/P4Nic3LbGjCP0YwrALHW1uNLKZ0LIMg+RF+XRlj2ekT9ZlZAQ== + dependencies: + loader-utils "^1.1.0" + genfun@^5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/genfun/-/genfun-5.0.0.tgz#9dd9710a06900a5c4a5bf57aca5da4e52fe76537" @@ -9415,6 +9535,11 @@ has-ansi@^2.0.0: dependencies: ansi-regex "^2.0.0" +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + integrity sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo= + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -9846,6 +9971,11 @@ iconv-lite@0.4.24, iconv-lite@^0.4.21, iconv-lite@^0.4.24, iconv-lite@~0.4.13: dependencies: safer-buffer ">= 2.1.2 < 3" +icss-replace-symbols@1.1.0, icss-replace-symbols@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz#06ea6f83679a7749e386cfe1fe812ae5db223ded" + integrity sha1-Bupvg2ead0njhs/h/oEq5dsiPe0= + icss-utils@^4.0.0, icss-utils@^4.1.1: version "4.1.1" resolved "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467" @@ -9907,7 +10037,7 @@ immer@1.10.0: resolved "https://registry.npmjs.org/immer/-/immer-1.10.0.tgz#bad67605ba9c810275d91e1c2a47d4582e98286d" integrity sha512-O3sR1/opvCDGLEVcvrGTMtLac8GJ5IwZC4puPrLuRj3l7ICKvkmA0vGuU9OW8mV9WIBRnaxp5GJh9IEAaNOoYg== -import-cwd@^2.0.0: +import-cwd@^2.0.0, import-cwd@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9" integrity sha1-qmzzbnInYShcs3HsZRn1PiQ1sKk= @@ -10462,6 +10592,11 @@ is-map@^2.0.1: resolved "https://registry.npmjs.org/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1" integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw== +is-module@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" + integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= + is-npm@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" @@ -10561,6 +10696,13 @@ is-redirect@^1.0.0: resolved "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ= +is-reference@^1.1.2: + version "1.1.4" + resolved "https://registry.npmjs.org/is-reference/-/is-reference-1.1.4.tgz#3f95849886ddb70256a3e6d062b1a68c13c51427" + integrity sha512-uJA/CDPO3Tao3GTrxYn6AwkM4nUPJiGGYu5+cB8qbC7WGFlrKZbiRo7SFKxUAEpFUfiHofWCXBUNhvYJMh+6zw== + dependencies: + "@types/estree" "0.0.39" + is-regex@^1.0.4, is-regex@^1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" @@ -12400,6 +12542,11 @@ lodash._root@~3.0.0: resolved "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" integrity sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI= +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= + lodash.capitalize@^4.2.1: version "4.2.1" resolved "https://registry.npmjs.org/lodash.capitalize/-/lodash.capitalize-4.2.1.tgz#f826c9b4e2a8511d84e3aca29db05e1a4f3b72a9" @@ -12615,6 +12762,13 @@ macos-release@^2.2.0: resolved "https://registry.npmjs.org/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f" integrity sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA== +magic-string@^0.25.2: + version "0.25.7" + resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" + integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA== + dependencies: + sourcemap-codec "^1.4.4" + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -14189,6 +14343,11 @@ p-pipe@^1.2.0: resolved "https://registry.npmjs.org/p-pipe/-/p-pipe-1.2.0.tgz#4b1a11399a11520a67790ee5a0c1d5881d6befe9" integrity sha1-SxoROZoRUgpneQ7loMHViB1r7+k= +p-queue@^2.4.2: + version "2.4.2" + resolved "https://registry.npmjs.org/p-queue/-/p-queue-2.4.2.tgz#03609826682b743be9a22dba25051bd46724fc34" + integrity sha512-n8/y+yDJwBjoLQe1GSJbbaYQLTI7QHNZI2+rpmCDbe++WLf9HC3gf6iqj5yfPAV71W4UF3ql5W1+UBPXoXTxng== + p-queue@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/p-queue/-/p-queue-4.0.0.tgz#ed0eee8798927ed6f2c2f5f5b77fdb2061a5d346" @@ -15007,6 +15166,13 @@ postcss-minify-selectors@^4.0.2: postcss "^7.0.0" postcss-selector-parser "^3.0.0" +postcss-modules-extract-imports@1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-1.1.0.tgz#b614c9720be6816eaee35fb3a5faa1dba6a05ddb" + integrity sha1-thTJcgvmgW6u41+zpfqh26agXds= + dependencies: + postcss "^6.0.1" + postcss-modules-extract-imports@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-2.0.0.tgz#818719a1ae1da325f9832446b01136eeb493cd7e" @@ -15014,6 +15180,14 @@ postcss-modules-extract-imports@^2.0.0: dependencies: postcss "^7.0.5" +postcss-modules-local-by-default@1.2.0: + version "1.2.0" + resolved "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-1.2.0.tgz#f7d80c398c5a393fa7964466bd19500a7d61c069" + integrity sha1-99gMOYxaOT+nlkRmvRlQCn1hwGk= + dependencies: + css-selector-tokenizer "^0.7.0" + postcss "^6.0.1" + postcss-modules-local-by-default@^3.0.2: version "3.0.2" resolved "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.2.tgz#e8a6561be914aaf3c052876377524ca90dbb7915" @@ -15024,6 +15198,14 @@ postcss-modules-local-by-default@^3.0.2: postcss-selector-parser "^6.0.2" postcss-value-parser "^4.0.0" +postcss-modules-scope@1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-1.1.0.tgz#d6ea64994c79f97b62a72b426fbe6056a194bb90" + integrity sha1-1upkmUx5+XtipytCb75gVqGUu5A= + dependencies: + css-selector-tokenizer "^0.7.0" + postcss "^6.0.1" + postcss-modules-scope@^2.1.1: version "2.2.0" resolved "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-2.2.0.tgz#385cae013cc7743f5a7d7602d1073a89eaae62ee" @@ -15032,6 +15214,14 @@ postcss-modules-scope@^2.1.1: postcss "^7.0.6" postcss-selector-parser "^6.0.0" +postcss-modules-values@1.3.0: + version "1.3.0" + resolved "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-1.3.0.tgz#ecffa9d7e192518389f42ad0e83f72aec456ea20" + integrity sha1-7P+p1+GSUYOJ9CrQ6D9yrsRW6iA= + dependencies: + icss-replace-symbols "^1.1.0" + postcss "^6.0.1" + postcss-modules-values@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-3.0.0.tgz#5b5000d6ebae29b4255301b4a3a54574423e7f10" @@ -15040,6 +15230,17 @@ postcss-modules-values@^3.0.0: icss-utils "^4.0.0" postcss "^7.0.6" +postcss-modules@^1.4.1: + version "1.5.0" + resolved "https://registry.npmjs.org/postcss-modules/-/postcss-modules-1.5.0.tgz#08da6ce43fcfadbc685a021fe6ed30ef929f0bcc" + integrity sha512-KiAihzcV0TxTTNA5OXreyIXctuHOfR50WIhqBpc8pe0Q5dcs/Uap9EVlifOI9am7zGGdGOJQ6B1MPYKo2UxgOg== + dependencies: + css-modules-loader-core "^1.1.0" + generic-names "^2.0.1" + lodash.camelcase "^4.3.0" + postcss "^7.0.1" + string-hash "^1.1.1" + postcss-nesting@^7.0.0: version "7.0.1" resolved "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-7.0.1.tgz#b50ad7b7f0173e5b5e3880c3501344703e04c052" @@ -15336,6 +15537,24 @@ postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1: indexes-of "^1.0.1" uniq "^1.0.1" +"postcss@5 - 7", postcss@^7, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.23, postcss@^7.0.26, postcss@^7.0.27, postcss@^7.0.5, postcss@^7.0.6: + version "7.0.27" + resolved "https://registry.npmjs.org/postcss/-/postcss-7.0.27.tgz#cc67cdc6b0daa375105b7c424a85567345fc54d9" + integrity sha512-WuQETPMcW9Uf1/22HWUWP9lgsIC+KEHg2kozMflKjbeUtw9ujvFX6QmIfozaErDkmLWS9WEnEdEe6Uo9/BNTdQ== + dependencies: + chalk "^2.4.2" + source-map "^0.6.1" + supports-color "^6.1.0" + +postcss@6.0.1: + version "6.0.1" + resolved "https://registry.npmjs.org/postcss/-/postcss-6.0.1.tgz#000dbd1f8eef217aa368b9a212c5fc40b2a8f3f2" + integrity sha1-AA29H47vIXqjaLmiEsX8QLKo8/I= + dependencies: + chalk "^1.1.3" + source-map "^0.5.6" + supports-color "^3.2.3" + postcss@7.0.21: version "7.0.21" resolved "https://registry.npmjs.org/postcss/-/postcss-7.0.21.tgz#06bb07824c19c2021c5d056d5b10c35b989f7e17" @@ -15345,14 +15564,14 @@ postcss@7.0.21: source-map "^0.6.1" supports-color "^6.1.0" -postcss@^7, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.23, postcss@^7.0.26, postcss@^7.0.27, postcss@^7.0.5, postcss@^7.0.6: - version "7.0.27" - resolved "https://registry.npmjs.org/postcss/-/postcss-7.0.27.tgz#cc67cdc6b0daa375105b7c424a85567345fc54d9" - integrity sha512-WuQETPMcW9Uf1/22HWUWP9lgsIC+KEHg2kozMflKjbeUtw9ujvFX6QmIfozaErDkmLWS9WEnEdEe6Uo9/BNTdQ== +postcss@^6.0.1: + version "6.0.23" + resolved "https://registry.npmjs.org/postcss/-/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324" + integrity sha512-soOk1h6J3VMTZtVeVpv15/Hpdl2cBLX3CAw4TAbkpTJiNPk9YP/zWcD1ND+xEtvyuuvKzbxliTOIyvkSeSJ6ag== dependencies: - chalk "^2.4.2" + chalk "^2.4.1" source-map "^0.6.1" - supports-color "^6.1.0" + supports-color "^5.4.0" prelude-ls@~1.1.2: version "1.1.2" @@ -15474,6 +15693,11 @@ promise.prototype.finally@^3.1.0: es-abstract "^1.17.0-next.0" function-bind "^1.1.1" +promise.series@^0.2.0: + version "0.2.0" + resolved "https://registry.npmjs.org/promise.series/-/promise.series-0.2.0.tgz#2cc7ebe959fc3a6619c04ab4dbdc9e452d864bbd" + integrity sha1-LMfr6Vn8OmYZwEq029yeRS2GS70= + promise@^7.1.1: version "7.3.1" resolved "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" @@ -16467,7 +16691,7 @@ regexpp@^3.0.0: resolved "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz#dd63982ee3300e67b41c1956f850aa680d9d330e" integrity sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g== -regexpu-core@^4.7.0: +regexpu-core@^4.6.0, regexpu-core@^4.7.0: version "4.7.0" resolved "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.7.0.tgz#fcbf458c50431b0bb7b45d6967b8192d91f3d938" integrity sha512-TQ4KXRnIn6tz6tjnrXEkD/sshygKH/j5KzK86X8MkeHyZ8qst/LZ89j3X4/8HEIfHANTFIP/AbXakeRhWIl5YQ== @@ -16741,7 +16965,7 @@ resolve@1.15.0: dependencies: path-parse "^1.0.6" -resolve@1.x, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.15.1, resolve@^1.3.2, resolve@^1.8.1: +resolve@1.15.1, resolve@1.x, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: version "1.15.1" resolved "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8" integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w== @@ -16849,6 +17073,88 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" +rollup-plugin-image-files@^1.4.2: + version "1.4.2" + resolved "https://registry.npmjs.org/rollup-plugin-image-files/-/rollup-plugin-image-files-1.4.2.tgz#0a329723bace95168a9a6efdacb51370c14fbfe5" + integrity sha512-tlydpQdGFssMWhPdWA9SFh4IGVSCzceNgJarJDID+km151IeIVzjATl8ZERNGS/QwMty25iammQqauxl1VUqDQ== + dependencies: + rollup "0.64.1" + rollup-pluginutils "2.4.1" + +rollup-plugin-peer-deps-external@^2.2.2: + version "2.2.2" + resolved "https://registry.npmjs.org/rollup-plugin-peer-deps-external/-/rollup-plugin-peer-deps-external-2.2.2.tgz#506cef67fb68f41cca3ec08ca6ff7936b190f568" + integrity sha512-XcHH4UW9exRTAf73d8rk2dw2UgF//cWbilhRI4Ni/n+t0zA1eBtohKyJROn0fxa4/+WZ5R3onAyIDiwRQL+59A== + +rollup-plugin-postcss@^2.5.0: + version "2.5.0" + resolved "https://registry.npmjs.org/rollup-plugin-postcss/-/rollup-plugin-postcss-2.5.0.tgz#54ef2487cda498d8bca69aaca3b55b30dee0106b" + integrity sha512-tBba0iMOY+eH1bP2rUhO/WK45uTRdRbuM5yWViO7tUChUrgA+JSQJscpCpStebPZoFxRwfkJRk2PZHd1q+JY2A== + dependencies: + chalk "^2.4.2" + concat-with-sourcemaps "^1.0.5" + cssnano "^4.1.8" + import-cwd "^2.1.0" + p-queue "^2.4.2" + pify "^3.0.0" + postcss "^7.0.14" + postcss-load-config "^2.0.0" + postcss-modules "^1.4.1" + promise.series "^0.2.0" + resolve "^1.5.0" + rollup-pluginutils "^2.0.1" + safe-identifier "^0.3.1" + style-inject "^0.3.0" + +rollup-plugin-typescript2@^0.26.0: + version "0.26.0" + resolved "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.26.0.tgz#cee2b44d51d9623686656d76dc30a73c4de91672" + integrity sha512-lUK7XZVG77tu8dmv1L/0LZFlavED/5Yo6e4iMMl6fdox/yKdj4IFRRPPJEXNdmEaT1nDQQeCi7b5IwKHffMNeg== + dependencies: + find-cache-dir "^3.2.0" + fs-extra "8.1.0" + resolve "1.15.1" + rollup-pluginutils "2.8.2" + tslib "1.10.0" + +rollup-pluginutils@2.4.1: + version "2.4.1" + resolved "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.4.1.tgz#de43ab54965bbf47843599a7f3adceb723de38db" + integrity sha512-wesMQ9/172IJDIW/lYWm0vW0LiKe5Ekjws481R7z9WTRtmO59cqyM/2uUlxvf6yzm/fElFmHUobeQOYz46dZJw== + dependencies: + estree-walker "^0.6.0" + micromatch "^3.1.10" + +rollup-pluginutils@2.8.2, rollup-pluginutils@^2.0.1: + version "2.8.2" + resolved "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" + integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== + dependencies: + estree-walker "^0.6.1" + +rollup@0.64.1: + version "0.64.1" + resolved "https://registry.npmjs.org/rollup/-/rollup-0.64.1.tgz#9188ee368e5fcd43ffbc00ec414e72eeb5de87ba" + integrity sha512-+ThdVXrvonJdOTzyybMBipP0uz605Z8AnzWVY3rf+cSGnLO7uNkJBlN+9jXqWOomkvumXfm/esmBpA5d53qm7g== + dependencies: + "@types/estree" "0.0.39" + "@types/node" "*" + +rollup@^0.63.4: + version "0.63.5" + resolved "https://registry.npmjs.org/rollup/-/rollup-0.63.5.tgz#5543eecac9a1b83b7e1be598b5be84c9c0a089db" + integrity sha512-dFf8LpUNzIj3oE0vCvobX6rqOzHzLBoblyFp+3znPbjiSmSvOoK2kMKx+Fv9jYduG1rvcCfCveSgEaQHjWRF6g== + dependencies: + "@types/estree" "0.0.39" + "@types/node" "*" + +rollup@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/rollup/-/rollup-2.1.0.tgz#552e248e397a06b9c6db878c0564ca4ee06729c9" + integrity sha512-gfE1455AEazVVTJoeQtcOq/U6GSxwoj4XPSWVsuWmgIxj7sBQNLDOSA82PbdMe+cP8ql8fR1jogPFe8Wg8g4SQ== + optionalDependencies: + fsevents "~2.1.2" + rsvp@^4.8.4: version "4.8.5" resolved "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" @@ -16902,6 +17208,11 @@ safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== +safe-identifier@^0.3.1: + version "0.3.1" + resolved "https://registry.npmjs.org/safe-identifier/-/safe-identifier-0.3.1.tgz#466b956ef8558b10bbe15b87fedf470ab283cd39" + integrity sha512-+vr9lVsmciuoP1fz8w30qDcohwH2S/tb5dPGQ8zHmG9jQf7YHU2fIKGxxcDpeY38J0Dep+DdPMz8FszVZT0Mbw== + safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" @@ -17504,7 +17815,7 @@ source-map@^0.7.3: resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sourcemap-codec@^1.4.1: +sourcemap-codec@^1.4.1, sourcemap-codec@^1.4.4: version "1.4.8" resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== @@ -17788,6 +18099,11 @@ string-argv@0.3.1: resolved "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== +string-hash@^1.1.1: + version "1.1.3" + resolved "https://registry.npmjs.org/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b" + integrity sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs= + string-length@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed" @@ -18017,6 +18333,11 @@ strong-log-transformer@^2.0.0: minimist "^1.2.0" through "^2.3.4" +style-inject@^0.3.0: + version "0.3.0" + resolved "https://registry.npmjs.org/style-inject/-/style-inject-0.3.0.tgz#d21c477affec91811cc82355832a700d22bf8dd3" + integrity sha512-IezA2qp+vcdlhJaVm5SOdPPTUu0FCEqfNSli2vRuSIBbu5Nq5UvygTk/VzeCqfLz2Atj3dVII5QBKGZRZ0edzw== + style-loader@0.23.1: version "0.23.1" resolved "https://registry.npmjs.org/style-loader/-/style-loader-0.23.1.tgz#cb9154606f3e771ab6c4ab637026a1049174d925" @@ -18059,7 +18380,14 @@ supports-color@^2.0.0: resolved "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= -supports-color@^5.3.0, supports-color@^5.5.0: +supports-color@^3.2.3: + version "3.2.3" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" + integrity sha1-ZawFBLOVQXHYpklGsq48u4pfVPY= + dependencies: + has-flag "^1.0.0" + +supports-color@^5.3.0, supports-color@^5.4.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== @@ -18573,6 +18901,11 @@ ts-pnp@1.1.6, ts-pnp@^1.1.2, ts-pnp@^1.1.6: resolved "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.1.6.tgz#389a24396d425a0d3162e96d2b4638900fdc289a" integrity sha512-CrG5GqAAzMT7144Cl+UIFP7mz/iIhiy+xQ6GGcnjTezhALT02uPMRw7tgDSESgB5MsfKt55+GPWw4ir1kVtMIQ== +tslib@1.10.0: + version "1.10.0" + resolved "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" + integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== + tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.11.1" resolved "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" From 2f776924b44417fc763dace00c35387cc84b976f Mon Sep 17 00:00:00 2001 From: nikek Date: Fri, 27 Mar 2020 18:01:02 +0100 Subject: [PATCH 02/19] add notice --- .../cli/@types/rollup-plugin-image-files.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/cli/@types/rollup-plugin-image-files.d.ts b/packages/cli/@types/rollup-plugin-image-files.d.ts index ba8ac05645..9ddc2c2351 100644 --- a/packages/cli/@types/rollup-plugin-image-files.d.ts +++ b/packages/cli/@types/rollup-plugin-image-files.d.ts @@ -1 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + declare module 'rollup-plugin-image-files'; From e4195998cef96d3564185c54fc81481f32bb8e9a Mon Sep 17 00:00:00 2001 From: Marcus Eide Date: Tue, 31 Mar 2020 11:48:25 +0200 Subject: [PATCH 03/19] Fix tests by building two versions of plugins and importing/exporting seperatly --- .gitignore | 1 + packages/app/src/plugins.ts | 5 +- packages/cli/src/commands/plugin/build.ts | 18 ++++--- .../cli/src/commands/plugin/rollup.config.ts | 49 ++++++++++++------- plugins/home-page/package.json | 1 + plugins/welcome/package.json | 3 +- 6 files changed, 47 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index f124971429..f5794babbc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ cjs/ esm/ types/ +build/ # Logs logs diff --git a/packages/app/src/plugins.ts b/packages/app/src/plugins.ts index 3c757a59c9..4a85a47cbf 100644 --- a/packages/app/src/plugins.ts +++ b/packages/app/src/plugins.ts @@ -1,3 +1,4 @@ /* eslint-disable notice/notice */ -export { default as HomePagePlugin } from '@backstage/plugin-home-page'; -export { default as WelcomePlugin } from '@backstage/plugin-welcome'; +import { default as HomePagePlugin } from '@backstage/plugin-home-page'; +import { default as WelcomePlugin } from '@backstage/plugin-welcome'; +export { HomePagePlugin, WelcomePlugin }; diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 1cbfd72413..591762618f 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -18,13 +18,15 @@ const rollup = require('rollup'); // "import" is not working for some reason... import rollupConfig from './rollup.config'; export default async () => { - const inputOptions = { - input: rollupConfig.input, - plugins: rollupConfig.plugins, - }; - const outputOptions = rollupConfig.output; + for (const config of rollupConfig) { + const inputOptions = { + input: config.input, + plugins: config.plugins, + }; + const outputOptions = config.output; - const bundle = await rollup.rollup(inputOptions); - await bundle.generate(outputOptions); - await bundle.write(outputOptions); + const bundle = await rollup.rollup(inputOptions); + await bundle.generate(outputOptions); + await bundle.write(outputOptions); + } }; diff --git a/packages/cli/src/commands/plugin/rollup.config.ts b/packages/cli/src/commands/plugin/rollup.config.ts index 85287ae752..fd2ae756bd 100644 --- a/packages/cli/src/commands/plugin/rollup.config.ts +++ b/packages/cli/src/commands/plugin/rollup.config.ts @@ -21,23 +21,34 @@ import resolve from '@rollup/plugin-node-resolve'; import postcss from 'rollup-plugin-postcss'; import image from 'rollup-plugin-image-files'; -export default { - input: 'src/index.ts', - output: { - file: 'build/index.esm.js', - format: 'esm', - sourcemap: true, - }, +const plugins = [ + peerDepsExternal(), + resolve(), + commonjs({ + include: ['node_modules/**', '../../node_modules/**'], + exclude: ['**/*.stories.js'], + }), + postcss(), + image(), + typescript(), +]; - plugins: [ - peerDepsExternal(), - resolve(), - commonjs({ - include: ['node_modules/**', '../../node_modules/**'], - exclude: ['**/*.stories.js'], - }), - postcss(), - image(), - typescript(), - ], -}; +export default [ + { + input: 'src/index.ts', + output: { + file: 'build/index.esm.js', + format: 'esm', + sourcemap: true, + }, + plugins, + }, + { + input: 'src/index.ts', + output: { + file: 'build/index.cjs.js', + format: 'cjs', + }, + plugins, + }, +]; diff --git a/plugins/home-page/package.json b/plugins/home-page/package.json index cd755627bd..ae4da55df6 100644 --- a/plugins/home-page/package.json +++ b/plugins/home-page/package.json @@ -1,6 +1,7 @@ { "name": "@backstage/plugin-home-page", "version": "0.1.1-alpha.0", + "main": "build/index.cjs.js", "module": "build/index.esm.js", "types": "build/index.d.ts", "license": "Apache-2.0", diff --git a/plugins/welcome/package.json b/plugins/welcome/package.json index 97a2a08772..a90d2e0a90 100644 --- a/plugins/welcome/package.json +++ b/plugins/welcome/package.json @@ -1,10 +1,11 @@ { "name": "@backstage/plugin-welcome", "version": "0.1.1-alpha.0", + "main": "build/index.cjs.js", "module": "build/index.esm.js", "types": "build/index.d.ts", - "license": "Apache-2.0", "private": false, + "license": "Apache-2.0", "scripts": { "build": "backstage-cli build-cache -- backstage-cli plugin:build", "lint": "backstage-cli lint", From b3a7057191fae9945dbadc2446b40284e1dd5299 Mon Sep 17 00:00:00 2001 From: Raghunandan Date: Tue, 31 Mar 2020 14:48:32 +0200 Subject: [PATCH 04/19] remove esm and use cjs output from plugins --- packages/cli/package.json | 2 +- packages/cli/src/commands/plugin/build.ts | 18 ++++--- .../cli/src/commands/plugin/rollup.config.ts | 47 +++++++------------ .../templates/default-plugin/package.json.hbs | 2 +- plugins/home-page/package.json | 1 - plugins/welcome/package.json | 1 - yarn.lock | 35 +++++++++++--- 7 files changed, 55 insertions(+), 51 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index db268ebc25..43ea2f3274 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -61,7 +61,7 @@ "inquirer": "^7.0.4", "ora": "^4.0.3", "react-dev-utils": "^10.2.0", - "react-scripts": "^3.4.0", + "react-scripts": "^3.4.1", "recursive-readdir": "^2.2.2", "replace-in-file": "^5.0.2", "rollup": "^2.1.0", diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 591762618f..1cbfd72413 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -18,15 +18,13 @@ const rollup = require('rollup'); // "import" is not working for some reason... import rollupConfig from './rollup.config'; export default async () => { - for (const config of rollupConfig) { - const inputOptions = { - input: config.input, - plugins: config.plugins, - }; - const outputOptions = config.output; + const inputOptions = { + input: rollupConfig.input, + plugins: rollupConfig.plugins, + }; + const outputOptions = rollupConfig.output; - const bundle = await rollup.rollup(inputOptions); - await bundle.generate(outputOptions); - await bundle.write(outputOptions); - } + const bundle = await rollup.rollup(inputOptions); + await bundle.generate(outputOptions); + await bundle.write(outputOptions); }; diff --git a/packages/cli/src/commands/plugin/rollup.config.ts b/packages/cli/src/commands/plugin/rollup.config.ts index fd2ae756bd..da53e6ddcd 100644 --- a/packages/cli/src/commands/plugin/rollup.config.ts +++ b/packages/cli/src/commands/plugin/rollup.config.ts @@ -21,34 +21,21 @@ import resolve from '@rollup/plugin-node-resolve'; import postcss from 'rollup-plugin-postcss'; import image from 'rollup-plugin-image-files'; -const plugins = [ - peerDepsExternal(), - resolve(), - commonjs({ - include: ['node_modules/**', '../../node_modules/**'], - exclude: ['**/*.stories.js'], - }), - postcss(), - image(), - typescript(), -]; - -export default [ - { - input: 'src/index.ts', - output: { - file: 'build/index.esm.js', - format: 'esm', - sourcemap: true, - }, - plugins, +export default { + input: 'src/index.ts', + output: { + file: 'build/index.cjs.js', + format: 'cjs', }, - { - input: 'src/index.ts', - output: { - file: 'build/index.cjs.js', - format: 'cjs', - }, - plugins, - }, -]; + plugins: [ + peerDepsExternal(), + resolve(), + commonjs({ + include: ['node_modules/**', '../../node_modules/**'], + exclude: ['**/*.stories.js'], + }), + postcss(), + image(), + typescript(), + ], +}; diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index 3e7e546170..a862b03f6e 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -1,7 +1,7 @@ { "name": "@backstage/plugin-{{id}}", "version": "{{version}}", - "main": "build/index.esm.js", + "main": "build/index.cjs.js", "types": "build/index.d.ts", "license": "Apache-2.0", "private": true, diff --git a/plugins/home-page/package.json b/plugins/home-page/package.json index ae4da55df6..fdde5b3f41 100644 --- a/plugins/home-page/package.json +++ b/plugins/home-page/package.json @@ -2,7 +2,6 @@ "name": "@backstage/plugin-home-page", "version": "0.1.1-alpha.0", "main": "build/index.cjs.js", - "module": "build/index.esm.js", "types": "build/index.d.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/welcome/package.json b/plugins/welcome/package.json index a90d2e0a90..4d0ea4577c 100644 --- a/plugins/welcome/package.json +++ b/plugins/welcome/package.json @@ -2,7 +2,6 @@ "name": "@backstage/plugin-welcome", "version": "0.1.1-alpha.0", "main": "build/index.cjs.js", - "module": "build/index.esm.js", "types": "build/index.d.ts", "private": false, "license": "Apache-2.0", diff --git a/yarn.lock b/yarn.lock index b844a4952f..ba8ea8e4e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6669,6 +6669,14 @@ cross-env@^7.0.0: dependencies: cross-spawn "^7.0.1" +cross-fetch@^3.0.4: + version "3.0.4" + resolved "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz#7bef7020207e684a7638ef5f2f698e24d9eb283c" + integrity sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw== + dependencies: + node-fetch "2.6.0" + whatwg-fetch "3.0.0" + cross-spawn-promise@^0.10.1: version "0.10.2" resolved "https://registry.npmjs.org/cross-spawn-promise/-/cross-spawn-promise-0.10.2.tgz#0e6338149caf53a6d557ac5c65efb3086d8704ac" @@ -11192,6 +11200,14 @@ jest-environment-node@^25.1.0: jest-mock "^25.1.0" jest-util "^25.1.0" +jest-fetch-mock@^3.0.3: + version "3.0.3" + resolved "https://registry.npmjs.org/jest-fetch-mock/-/jest-fetch-mock-3.0.3.tgz#31749c456ae27b8919d69824f1c2bd85fe0a1f3b" + integrity sha512-Ux1nWprtLrdrH4XwE7O7InRY6psIi3GOsqNESJgMJ+M5cv4A8Lh7SN9d2V2kKRZ8ebAfcd1LNyZguAOb6JiDqw== + dependencies: + cross-fetch "^3.0.4" + promise-polyfill "^8.1.3" + jest-get-type@^24.9.0: version "24.9.0" resolved "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.9.0.tgz#1684a0c8a50f2e4901b6644ae861f579eed2ef0e" @@ -13497,6 +13513,11 @@ node-fetch-npm@^2.0.2: json-parse-better-errors "^1.0.0" safe-buffer "^5.1.1" +node-fetch@2.6.0, node-fetch@^2.3.0, node-fetch@^2.5.0, node-fetch@^2.6.0: + version "2.6.0" + resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" + integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== + node-fetch@^1.0.1: version "1.7.3" resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" @@ -13505,11 +13526,6 @@ node-fetch@^1.0.1: encoding "^0.1.11" is-stream "^1.0.1" -node-fetch@^2.3.0, node-fetch@^2.5.0, node-fetch@^2.6.0: - version "2.6.0" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" - integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== - node-forge@0.9.0: version "0.9.0" resolved "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579" @@ -15665,6 +15681,11 @@ promise-inflight@^1.0.1, promise-inflight@~1.0.1: resolved "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= +promise-polyfill@^8.1.3: + version "8.1.3" + resolved "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.1.3.tgz#8c99b3cf53f3a91c68226ffde7bde81d7f904116" + integrity sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g== + promise-retry@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/promise-retry/-/promise-retry-1.1.1.tgz#6739e968e3051da20ce6497fb2b50f6911df3d6d" @@ -16223,7 +16244,7 @@ react-router@5.1.2: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" -react-scripts@^3.4.0: +react-scripts@^3.4.1: version "3.4.1" resolved "https://registry.npmjs.org/react-scripts/-/react-scripts-3.4.1.tgz#f551298b5c71985cc491b9acf3c8e8c0ae3ada0a" integrity sha512-JpTdi/0Sfd31mZA6Ukx+lq5j1JoKItX7qqEK4OiACjVQletM1P38g49d9/D0yTxp9FrSF+xpJFStkGgKEIRjlQ== @@ -19611,7 +19632,7 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3, whatwg-encoding@^1.0.5: dependencies: iconv-lite "0.4.24" -whatwg-fetch@>=0.10.0, whatwg-fetch@^3.0.0: +whatwg-fetch@3.0.0, whatwg-fetch@>=0.10.0, whatwg-fetch@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q== From dbb7ba14d1815fa7561202b6911cfcbc7eac4b13 Mon Sep 17 00:00:00 2001 From: nikek Date: Tue, 31 Mar 2020 18:06:18 +0200 Subject: [PATCH 05/19] add circumflex accent to rollup types deps --- packages/cli/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 43ea2f3274..2c4035ec81 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -33,8 +33,8 @@ "@types/react-dev-utils": "^9.0.4", "@types/recursive-readdir": "^2.2.0", "@types/tar": "^4.0.3", - "@types/rollup-plugin-peer-deps-external": "2.2.0", - "@types/rollup-plugin-postcss": "2.0.0", + "@types/rollup-plugin-peer-deps-external": "^2.2.0", + "@types/rollup-plugin-postcss": "^2.0.0", "@types/webpack": "^4.41.7", "@types/webpack-dev-server": "^3.10.0", "del": "^5.1.0", From 701bfff609cb4d9f1671d15f32da983ac6132f75 Mon Sep 17 00:00:00 2001 From: nikek Date: Tue, 31 Mar 2020 18:07:42 +0200 Subject: [PATCH 06/19] rename image to imageFiles to not confuse it with the image plugin --- packages/cli/src/commands/plugin/rollup.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/plugin/rollup.config.ts b/packages/cli/src/commands/plugin/rollup.config.ts index da53e6ddcd..40878157f4 100644 --- a/packages/cli/src/commands/plugin/rollup.config.ts +++ b/packages/cli/src/commands/plugin/rollup.config.ts @@ -19,7 +19,7 @@ import typescript from 'rollup-plugin-typescript2'; // @rollup/plugin-typescript import commonjs from '@rollup/plugin-commonjs'; import resolve from '@rollup/plugin-node-resolve'; import postcss from 'rollup-plugin-postcss'; -import image from 'rollup-plugin-image-files'; +import imageFiles from 'rollup-plugin-image-files'; export default { input: 'src/index.ts', @@ -35,7 +35,7 @@ export default { exclude: ['**/*.stories.js'], }), postcss(), - image(), + imageFiles(), typescript(), ], }; From 4e747b0a19725665687b061ec7fd96ffb65fec37 Mon Sep 17 00:00:00 2001 From: nikek Date: Tue, 31 Mar 2020 18:08:43 +0200 Subject: [PATCH 07/19] remove commented out code --- packages/cli/src/index.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 9687e100d1..251252fe43 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -143,6 +143,3 @@ process.on('unhandledRejection', rejection => { }); main(process.argv); -// process.chdir('../../plugins/welcome'); -// console.log(`DEBUG: ${process.cwd()}`); -// main([process.argv[0], process.argv[1], 'plugin:build']); From 32a112d63b8c848113bd114efc2837a178e93dfb Mon Sep 17 00:00:00 2001 From: nikek Date: Tue, 31 Mar 2020 18:26:12 +0200 Subject: [PATCH 08/19] rename build to dist again --- packages/cli/src/commands/plugin/rollup.config.ts | 2 +- packages/cli/templates/default-plugin/package.json.hbs | 4 ++-- plugins/home-page/package.json | 4 ++-- plugins/welcome/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/commands/plugin/rollup.config.ts b/packages/cli/src/commands/plugin/rollup.config.ts index 40878157f4..807c750be6 100644 --- a/packages/cli/src/commands/plugin/rollup.config.ts +++ b/packages/cli/src/commands/plugin/rollup.config.ts @@ -24,7 +24,7 @@ import imageFiles from 'rollup-plugin-image-files'; export default { input: 'src/index.ts', output: { - file: 'build/index.cjs.js', + file: 'dist/index.cjs.js', format: 'cjs', }, plugins: [ diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index a862b03f6e..e369784588 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -1,8 +1,8 @@ { "name": "@backstage/plugin-{{id}}", "version": "{{version}}", - "main": "build/index.cjs.js", - "types": "build/index.d.ts", + "main": "dist/index.cjs.js", + "types": "dist/index.d.ts", "license": "Apache-2.0", "private": true, "scripts": { diff --git a/plugins/home-page/package.json b/plugins/home-page/package.json index fdde5b3f41..a4b174e260 100644 --- a/plugins/home-page/package.json +++ b/plugins/home-page/package.json @@ -1,8 +1,8 @@ { "name": "@backstage/plugin-home-page", "version": "0.1.1-alpha.0", - "main": "build/index.cjs.js", - "types": "build/index.d.ts", + "main": "dist/index.cjs.js", + "types": "dist/index.d.ts", "license": "Apache-2.0", "private": false, "scripts": { diff --git a/plugins/welcome/package.json b/plugins/welcome/package.json index 4d0ea4577c..03bbfa0e96 100644 --- a/plugins/welcome/package.json +++ b/plugins/welcome/package.json @@ -1,8 +1,8 @@ { "name": "@backstage/plugin-welcome", "version": "0.1.1-alpha.0", - "main": "build/index.cjs.js", - "types": "build/index.d.ts", + "main": "dist/index.cjs.js", + "types": "dist/index.d.ts", "private": false, "license": "Apache-2.0", "scripts": { From 0b4c3fd90e8ab02041c1f983d31f03d13c6f51c6 Mon Sep 17 00:00:00 2001 From: nikek Date: Tue, 31 Mar 2020 18:30:47 +0200 Subject: [PATCH 09/19] update yarn.lock for rollup deps --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index ba8ea8e4e9..9cbd263dea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3803,7 +3803,7 @@ resolved "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d" integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA== -"@types/rollup-plugin-peer-deps-external@2.2.0": +"@types/rollup-plugin-peer-deps-external@^2.2.0": version "2.2.0" resolved "https://registry.npmjs.org/@types/rollup-plugin-peer-deps-external/-/rollup-plugin-peer-deps-external-2.2.0.tgz#eae7d8b9d27fa037f5bcaded24e389f85b81973c" integrity sha512-BiztED+KYJPBI3ihLSOuuZSzy836WAOpC9UrMtDqk3+VeByR8A5pJJ9pCVnq/dfB4wyCeiFL+FlyJnqZuP3pxg== @@ -3811,7 +3811,7 @@ "@types/node" "*" rollup "^0.63.4" -"@types/rollup-plugin-postcss@2.0.0": +"@types/rollup-plugin-postcss@^2.0.0": version "2.0.0" resolved "https://registry.npmjs.org/@types/rollup-plugin-postcss/-/rollup-plugin-postcss-2.0.0.tgz#b1bcc686c7dbe441f2fcfb47cac01acc508f46c0" integrity sha512-lw4LvCcWpQ/Yomb9bxT69uAN5ZfW6nhL9itEu3z0IzsNNqKalwIDo7pEK8jxoiHQmcPaYzayAfo4M1JT/h8crw== From 8fffc427013ced8820a54e8a88d0d99f9e4b0cd6 Mon Sep 17 00:00:00 2001 From: nikek Date: Wed, 1 Apr 2020 10:33:53 +0200 Subject: [PATCH 10/19] remove unnecessary comment --- packages/cli/src/commands/plugin/rollup.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/plugin/rollup.config.ts b/packages/cli/src/commands/plugin/rollup.config.ts index 807c750be6..ad8a4c3270 100644 --- a/packages/cli/src/commands/plugin/rollup.config.ts +++ b/packages/cli/src/commands/plugin/rollup.config.ts @@ -15,7 +15,7 @@ */ import peerDepsExternal from 'rollup-plugin-peer-deps-external'; -import typescript from 'rollup-plugin-typescript2'; // @rollup/plugin-typescript +import typescript from 'rollup-plugin-typescript2'; import commonjs from '@rollup/plugin-commonjs'; import resolve from '@rollup/plugin-node-resolve'; import postcss from 'rollup-plugin-postcss'; From d43414d68742e7b78500a6361dbb21fdedc20ece Mon Sep 17 00:00:00 2001 From: nikek Date: Wed, 1 Apr 2020 11:30:36 +0200 Subject: [PATCH 11/19] put shared tsconfig in root config --- packages/cli/templates/default-plugin/tsconfig.json | 5 +---- plugins/home-page/tsconfig.json | 5 +---- plugins/welcome/tsconfig.json | 5 +---- tsconfig.json | 3 ++- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/cli/templates/default-plugin/tsconfig.json b/packages/cli/templates/default-plugin/tsconfig.json index 4721441081..596e2cf729 100644 --- a/packages/cli/templates/default-plugin/tsconfig.json +++ b/packages/cli/templates/default-plugin/tsconfig.json @@ -1,7 +1,4 @@ { "extends": "../../tsconfig.json", - "include": ["src"], - "compilerOptions": { - "module": "es6" - } + "include": ["src"] } diff --git a/plugins/home-page/tsconfig.json b/plugins/home-page/tsconfig.json index 4721441081..596e2cf729 100644 --- a/plugins/home-page/tsconfig.json +++ b/plugins/home-page/tsconfig.json @@ -1,7 +1,4 @@ { "extends": "../../tsconfig.json", - "include": ["src"], - "compilerOptions": { - "module": "es6" - } + "include": ["src"] } diff --git a/plugins/welcome/tsconfig.json b/plugins/welcome/tsconfig.json index 4721441081..596e2cf729 100644 --- a/plugins/welcome/tsconfig.json +++ b/plugins/welcome/tsconfig.json @@ -1,7 +1,4 @@ { "extends": "../../tsconfig.json", - "include": ["src"], - "compilerOptions": { - "module": "es6" - } + "include": ["src"] } diff --git a/tsconfig.json b/tsconfig.json index 25f61cc933..abb10087ca 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "allowJs": true, "noEmit": false, "declarationMap": true, - "incremental": true + "incremental": true, + "module": "es6" } } From e791907d1f17297e9a12304a8b98548f24d6480d Mon Sep 17 00:00:00 2001 From: nikek Date: Wed, 1 Apr 2020 11:32:56 +0200 Subject: [PATCH 12/19] WIP watch mode --- packages/cli/src/commands/plugin/build.ts | 26 +++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 1cbfd72413..6e5372247d 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -16,15 +16,33 @@ const rollup = require('rollup'); // "import" is not working for some reason... import rollupConfig from './rollup.config'; +import { Command } from 'commander'; +import { run } from '../../helpers/run'; -export default async () => { +export default async (cmd: Command) => { const inputOptions = { input: rollupConfig.input, plugins: rollupConfig.plugins, }; const outputOptions = rollupConfig.output; - const bundle = await rollup.rollup(inputOptions); - await bundle.generate(outputOptions); - await bundle.write(outputOptions); + if (cmd.watch) { + await run('rollup -c -w'); + // const watchOptions = { + // ...inputOptions, + // output: [outputOptions], + // watch: { + // include: ['src/**/*'], + // chokidar: true, + // }, + // }; + // const watcher = rollup.watch(watchOptions); + // watcher.on('event', (event: any) => { + // process.stdout.write(event); + // }); + } else { + const bundle = await rollup.rollup(inputOptions); + await bundle.generate(outputOptions); + await bundle.write(outputOptions); + } }; From d4ac45b628f015372b1ec87f89ca527d41cfa58c Mon Sep 17 00:00:00 2001 From: nikek Date: Wed, 1 Apr 2020 23:24:11 +0200 Subject: [PATCH 13/19] make rollup watch mode work --- packages/cli/package.json | 2 +- packages/cli/src/commands/plugin/build.ts | 36 ++++++-------------- yarn.lock | 41 ++++++----------------- 3 files changed, 22 insertions(+), 57 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 2c4035ec81..1acf8673a9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -64,7 +64,7 @@ "react-scripts": "^3.4.1", "recursive-readdir": "^2.2.2", "replace-in-file": "^5.0.2", - "rollup": "^2.1.0", + "rollup": "^2.3.2", "rollup-plugin-image-files": "^1.4.2", "rollup-plugin-peer-deps-external": "^2.2.2", "rollup-plugin-postcss": "^2.5.0", diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 6e5372247d..4a8c68e1b8 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -14,35 +14,21 @@ * limitations under the License. */ -const rollup = require('rollup'); // "import" is not working for some reason... -import rollupConfig from './rollup.config'; +import { rollup, watch, RollupWatchOptions, OutputOptions } from 'rollup'; +import conf from './rollup.config'; import { Command } from 'commander'; -import { run } from '../../helpers/run'; export default async (cmd: Command) => { - const inputOptions = { - input: rollupConfig.input, - plugins: rollupConfig.plugins, - }; - const outputOptions = rollupConfig.output; - if (cmd.watch) { - await run('rollup -c -w'); - // const watchOptions = { - // ...inputOptions, - // output: [outputOptions], - // watch: { - // include: ['src/**/*'], - // chokidar: true, - // }, - // }; - // const watcher = rollup.watch(watchOptions); - // watcher.on('event', (event: any) => { - // process.stdout.write(event); - // }); + const watcher = watch(conf as RollupWatchOptions); + watcher.on('event', console.log); + await new Promise(() => {}); } else { - const bundle = await rollup.rollup(inputOptions); - await bundle.generate(outputOptions); - await bundle.write(outputOptions); + const bundle = await rollup({ + input: conf.input, + plugins: conf.plugins, + }); + await bundle.generate(conf.output as OutputOptions); + await bundle.write(conf.output as OutputOptions); } }; diff --git a/yarn.lock b/yarn.lock index 9cbd263dea..d29ca8d457 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6669,14 +6669,6 @@ cross-env@^7.0.0: dependencies: cross-spawn "^7.0.1" -cross-fetch@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz#7bef7020207e684a7638ef5f2f698e24d9eb283c" - integrity sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw== - dependencies: - node-fetch "2.6.0" - whatwg-fetch "3.0.0" - cross-spawn-promise@^0.10.1: version "0.10.2" resolved "https://registry.npmjs.org/cross-spawn-promise/-/cross-spawn-promise-0.10.2.tgz#0e6338149caf53a6d557ac5c65efb3086d8704ac" @@ -11200,14 +11192,6 @@ jest-environment-node@^25.1.0: jest-mock "^25.1.0" jest-util "^25.1.0" -jest-fetch-mock@^3.0.3: - version "3.0.3" - resolved "https://registry.npmjs.org/jest-fetch-mock/-/jest-fetch-mock-3.0.3.tgz#31749c456ae27b8919d69824f1c2bd85fe0a1f3b" - integrity sha512-Ux1nWprtLrdrH4XwE7O7InRY6psIi3GOsqNESJgMJ+M5cv4A8Lh7SN9d2V2kKRZ8ebAfcd1LNyZguAOb6JiDqw== - dependencies: - cross-fetch "^3.0.4" - promise-polyfill "^8.1.3" - jest-get-type@^24.9.0: version "24.9.0" resolved "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.9.0.tgz#1684a0c8a50f2e4901b6644ae861f579eed2ef0e" @@ -13513,11 +13497,6 @@ node-fetch-npm@^2.0.2: json-parse-better-errors "^1.0.0" safe-buffer "^5.1.1" -node-fetch@2.6.0, node-fetch@^2.3.0, node-fetch@^2.5.0, node-fetch@^2.6.0: - version "2.6.0" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" - integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== - node-fetch@^1.0.1: version "1.7.3" resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" @@ -13526,6 +13505,11 @@ node-fetch@^1.0.1: encoding "^0.1.11" is-stream "^1.0.1" +node-fetch@^2.3.0, node-fetch@^2.5.0, node-fetch@^2.6.0: + version "2.6.0" + resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" + integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== + node-forge@0.9.0: version "0.9.0" resolved "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579" @@ -15681,11 +15665,6 @@ promise-inflight@^1.0.1, promise-inflight@~1.0.1: resolved "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= -promise-polyfill@^8.1.3: - version "8.1.3" - resolved "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.1.3.tgz#8c99b3cf53f3a91c68226ffde7bde81d7f904116" - integrity sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g== - promise-retry@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/promise-retry/-/promise-retry-1.1.1.tgz#6739e968e3051da20ce6497fb2b50f6911df3d6d" @@ -17169,10 +17148,10 @@ rollup@^0.63.4: "@types/estree" "0.0.39" "@types/node" "*" -rollup@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/rollup/-/rollup-2.1.0.tgz#552e248e397a06b9c6db878c0564ca4ee06729c9" - integrity sha512-gfE1455AEazVVTJoeQtcOq/U6GSxwoj4XPSWVsuWmgIxj7sBQNLDOSA82PbdMe+cP8ql8fR1jogPFe8Wg8g4SQ== +rollup@^2.3.2: + version "2.3.2" + resolved "https://registry.npmjs.org/rollup/-/rollup-2.3.2.tgz#afa68e4f3325bcef4e150d082056bef450bcac60" + integrity sha512-p66+fbfaUUOGE84sHXAOgfeaYQMslgAazoQMp//nlR519R61213EPFgrMZa48j31jNacJwexSAR1Q8V/BwGKBA== optionalDependencies: fsevents "~2.1.2" @@ -19632,7 +19611,7 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3, whatwg-encoding@^1.0.5: dependencies: iconv-lite "0.4.24" -whatwg-fetch@3.0.0, whatwg-fetch@>=0.10.0, whatwg-fetch@^3.0.0: +whatwg-fetch@>=0.10.0, whatwg-fetch@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q== From 8c1c8d2f5a098a98493bb8aa8ac302f868e4061e Mon Sep 17 00:00:00 2001 From: nikek Date: Thu, 2 Apr 2020 10:29:52 +0200 Subject: [PATCH 14/19] tweak types --- packages/cli/src/commands/plugin/build.ts | 4 ++-- packages/cli/src/commands/plugin/rollup.config.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 4a8c68e1b8..ac8193c0fb 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -14,13 +14,13 @@ * limitations under the License. */ -import { rollup, watch, RollupWatchOptions, OutputOptions } from 'rollup'; +import { rollup, watch, OutputOptions } from 'rollup'; import conf from './rollup.config'; import { Command } from 'commander'; export default async (cmd: Command) => { if (cmd.watch) { - const watcher = watch(conf as RollupWatchOptions); + const watcher = watch(conf); watcher.on('event', console.log); await new Promise(() => {}); } else { diff --git a/packages/cli/src/commands/plugin/rollup.config.ts b/packages/cli/src/commands/plugin/rollup.config.ts index ad8a4c3270..324a12a98c 100644 --- a/packages/cli/src/commands/plugin/rollup.config.ts +++ b/packages/cli/src/commands/plugin/rollup.config.ts @@ -20,6 +20,7 @@ import commonjs from '@rollup/plugin-commonjs'; import resolve from '@rollup/plugin-node-resolve'; import postcss from 'rollup-plugin-postcss'; import imageFiles from 'rollup-plugin-image-files'; +import { RollupWatchOptions } from 'rollup'; export default { input: 'src/index.ts', @@ -38,4 +39,4 @@ export default { imageFiles(), typescript(), ], -}; +} as RollupWatchOptions; From 91e8058c52d77faa7cdae223f1db22241acc3040 Mon Sep 17 00:00:00 2001 From: nikek Date: Thu, 2 Apr 2020 10:35:04 +0200 Subject: [PATCH 15/19] refactor plugin build function --- packages/cli/src/commands/plugin/build.ts | 33 ++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index ac8193c0fb..5bb9e171b0 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -20,15 +20,30 @@ import { Command } from 'commander'; export default async (cmd: Command) => { if (cmd.watch) { - const watcher = watch(conf); - watcher.on('event', console.log); - await new Promise(() => {}); - } else { - const bundle = await rollup({ - input: conf.input, - plugins: conf.plugins, + // We're not resolving this promise because watch() doesn't have any exit event. + // Instead we just wait until the user sends an interrupt signal. + return new Promise(() => { + const watcher = watch(conf); + watcher.on('event', event => { + // START — the watcher is (re)starting + // BUNDLE_START — building an individual bundle + // BUNDLE_END — finished building a bundle + // END — finished building all bundles + // ERROR — encountered an error while bundling + + if (event.code === 'ERROR') { + console.log(event.error); + } else { + console.log(event.code); + } + }); }); - await bundle.generate(conf.output as OutputOptions); - await bundle.write(conf.output as OutputOptions); } + + const bundle = await rollup({ + input: conf.input, + plugins: conf.plugins, + }); + await bundle.generate(conf.output as OutputOptions); + await bundle.write(conf.output as OutputOptions); }; From 43f37a53a0138e6e0e181a2e49b1a00cd5613aac Mon Sep 17 00:00:00 2001 From: nikek Date: Thu, 2 Apr 2020 10:38:08 +0200 Subject: [PATCH 16/19] add build:watch to package.json of plugins --- packages/cli/templates/default-plugin/package.json.hbs | 1 + plugins/home-page/package.json | 1 + plugins/welcome/package.json | 1 + 3 files changed, 3 insertions(+) diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index e369784588..1141eeb4cc 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -6,6 +6,7 @@ "license": "Apache-2.0", "private": true, "scripts": { + "build:watch": "backstage-cli plugin:build --watch", "build": "backstage-cli build-cache -- backstage-cli plugin:build", "lint": "backstage-cli lint", "test": "backstage-cli test" diff --git a/plugins/home-page/package.json b/plugins/home-page/package.json index a4b174e260..45431ee292 100644 --- a/plugins/home-page/package.json +++ b/plugins/home-page/package.json @@ -6,6 +6,7 @@ "license": "Apache-2.0", "private": false, "scripts": { + "build:watch": "backstage-cli plugin:build --watch", "build": "backstage-cli build-cache -- backstage-cli plugin:build", "lint": "backstage-cli lint", "test": "backstage-cli test" diff --git a/plugins/welcome/package.json b/plugins/welcome/package.json index 03bbfa0e96..dbf0ce1fc2 100644 --- a/plugins/welcome/package.json +++ b/plugins/welcome/package.json @@ -6,6 +6,7 @@ "private": false, "license": "Apache-2.0", "scripts": { + "build:watch": "backstage-cli plugin:build --watch", "build": "backstage-cli build-cache -- backstage-cli plugin:build", "lint": "backstage-cli lint", "test": "backstage-cli test" From d2447eada852c348fefcd4352002417efef34fa6 Mon Sep 17 00:00:00 2001 From: nikek Date: Thu, 2 Apr 2020 10:46:29 +0200 Subject: [PATCH 17/19] fix consistent return from plugin build --- packages/cli/src/commands/plugin/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 5bb9e171b0..cb28d4cf5f 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -22,7 +22,7 @@ export default async (cmd: Command) => { if (cmd.watch) { // We're not resolving this promise because watch() doesn't have any exit event. // Instead we just wait until the user sends an interrupt signal. - return new Promise(() => { + await new Promise(() => { const watcher = watch(conf); watcher.on('event', event => { // START — the watcher is (re)starting From a8ce7564fac29d916644f1ac5fbc5dd7f374d4d3 Mon Sep 17 00:00:00 2001 From: nikek Date: Thu, 2 Apr 2020 11:15:06 +0200 Subject: [PATCH 18/19] add notice to plugins.ts --- packages/app/src/plugins.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/app/src/plugins.ts b/packages/app/src/plugins.ts index 4a85a47cbf..c81c403ef7 100644 --- a/packages/app/src/plugins.ts +++ b/packages/app/src/plugins.ts @@ -1,4 +1,19 @@ -/* eslint-disable notice/notice */ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { default as HomePagePlugin } from '@backstage/plugin-home-page'; import { default as WelcomePlugin } from '@backstage/plugin-welcome'; export { HomePagePlugin, WelcomePlugin }; From e62618c9198fdc5fb4df1e4f1782e040d36a0167 Mon Sep 17 00:00:00 2001 From: nikek Date: Thu, 2 Apr 2020 11:57:14 +0200 Subject: [PATCH 19/19] add separate import and export in createPlugin --- .../commands/create-plugin/createPlugin.ts | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/commands/create-plugin/createPlugin.ts b/packages/cli/src/commands/create-plugin/createPlugin.ts index 1b35d99a59..7802f402f9 100644 --- a/packages/cli/src/commands/create-plugin/createPlugin.ts +++ b/packages/cli/src/commands/create-plugin/createPlugin.ts @@ -67,18 +67,21 @@ const sortObjectByKeys = (obj: { [name in string]: string }) => { const capitalize = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1); -async function addExportStatement(file: string, exportStatement: string) { - const contents = await fs.readFile(file, 'utf8'); - const newContents = contents +const addExportStatement = async ( + file: string, + importStatement: string, + exportStatement: string, +) => { + const newContents = fs + .readFileSync(file, 'utf8') .split('\n') .filter(Boolean) // get rid of empty lines - .concat([exportStatement]) - .sort() + .concat([importStatement, exportStatement]) .concat(['']) // newline at end of file .join('\n'); await fs.writeFile(file, newContents, 'utf8'); -} +}; export async function addPluginDependencyToApp( rootDir: string, @@ -118,16 +121,19 @@ export async function addPluginToApp(rootDir: string, pluginName: string) { .split('-') .map(name => capitalize(name)) .join(''); - const pluginExport = `export { default as ${pluginNameCapitalized} } from '${pluginPackage}';`; + const pluginImport = `import { default as ${pluginNameCapitalized} } from '${pluginPackage}';`; + const pluginExport = `export { ${pluginNameCapitalized} };`; const pluginsFilePath = 'packages/app/src/plugins.ts'; const pluginsFile = resolvePath(rootDir, pluginsFilePath); await Task.forItem('processing', pluginsFilePath, async () => { - await addExportStatement(pluginsFile, pluginExport).catch(error => { - throw new Error( - `Failed to import plugin in app: ${pluginsFile}: ${error.message}`, - ); - }); + await addExportStatement(pluginsFile, pluginImport, pluginExport).catch( + error => { + throw new Error( + `Failed to import plugin in app: ${pluginsFile}: ${error.message}`, + ); + }, + ); }); }