From 98183e072c53dec823a5ee308811631be11282ec Mon Sep 17 00:00:00 2001 From: Ben Scott Date: Tue, 8 Jan 2019 14:43:42 -0800 Subject: [PATCH] Remove all usages of babel-node That extra transpile step means an extra dependency but doesn't add any value --- .babelrc | 3 - config/rollup/index.js | 28 ++++---- config/rollup/namespaced-classname.js | 8 +-- config/rollup/plugins/icon.js | 12 ++-- config/rollup/plugins/image.js | 10 +-- config/rollup/plugins/styles.js | 34 +++++----- .../rollup/use-existing-classname-tokens.js | 4 +- package.json | 9 ++- scripts/build-consumer.js | 6 +- scripts/build.js | 18 ++--- scripts/open-styleguide-pr.js | 8 +-- scripts/sass-build.js | 16 ++--- yarn.lock | 68 +------------------ 13 files changed, 78 insertions(+), 146 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index eecbe0a2ce4..00000000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["shopify/node"] -} diff --git a/config/rollup/index.js b/config/rollup/index.js index 3754a759a72..dd84ee658d2 100644 --- a/config/rollup/index.js +++ b/config/rollup/index.js @@ -1,18 +1,18 @@ -import {resolve} from 'path'; -import {readJSONSync} from 'fs-extra'; -import nodeResolve from 'rollup-plugin-node-resolve'; -import babel from 'rollup-plugin-babel'; -import json from 'rollup-plugin-json'; -import commonjs from 'rollup-plugin-commonjs'; +const {resolve} = require('path'); +const {readJSONSync} = require('fs-extra'); +const nodeResolve = require('rollup-plugin-node-resolve'); +const babel = require('rollup-plugin-babel'); +const json = require('rollup-plugin-json'); +const commonjs = require('rollup-plugin-commonjs'); -import {dependencies, peerDependencies} from '../../package.json'; +const {dependencies, peerDependencies} = require('../../package.json'); -import styles from './plugins/styles'; -import image from './plugins/image'; -import icon from './plugins/icon'; +const styles = require('./plugins/styles'); +const image = require('./plugins/image'); +const icon = require('./plugins/icon'); -import getNamespacedClassName from './namespaced-classname'; -import createExistingClassnameTokenUser from './use-existing-classname-tokens'; +const getNamespacedClassName = require('./namespaced-classname'); +const createExistingClassnameTokenUser = require('./use-existing-classname-tokens'); const project = resolve(__dirname, '../..'); const buildRoot = resolve(project, './build-intermediate'); @@ -27,7 +27,7 @@ const sassResources = [ resolve(styleRoot, './shared.scss'), ]; -export default function createRollupConfig({ +module.exports = function createRollupConfig({ entry, writeCSS, cssPath, @@ -78,4 +78,4 @@ export default function createRollupConfig({ }), ], }; -} +}; diff --git a/config/rollup/namespaced-classname.js b/config/rollup/namespaced-classname.js index b153d4ea681..3edafced04f 100644 --- a/config/rollup/namespaced-classname.js +++ b/config/rollup/namespaced-classname.js @@ -1,5 +1,5 @@ -import {basename} from 'path'; -import {camelCase} from 'change-case'; +const {basename} = require('path'); +const {camelCase} = require('change-case'); const cache = { files: {}, @@ -9,7 +9,7 @@ const COMPONENT_REGEX = /^[A-Z]\w+$/; const SUBCOMPONENT_VARIATION_SELECTOR = /^\w+-\w+$/; const NESTED_COMPONENT_PATH_REGEX = /.*\/components\/(.*)\/components/; -export default function getNamespacedClassName(localName, filePath) { +module.exports = function getNamespacedClassName(localName, filePath) { const file = cache.files[filePath] || {}; const componentName = basename(filePath, '.scss'); const nestedComponentMatch = NESTED_COMPONENT_PATH_REGEX.exec(filePath); @@ -45,7 +45,7 @@ export default function getNamespacedClassName(localName, filePath) { file[localName] = className; cache.files[filePath] = file; return className; -} +}; function isComponent(className) { return COMPONENT_REGEX.test(className); diff --git a/config/rollup/plugins/icon.js b/config/rollup/plugins/icon.js index ec45429cb96..2302e80210c 100644 --- a/config/rollup/plugins/icon.js +++ b/config/rollup/plugins/icon.js @@ -1,8 +1,8 @@ -import {extname} from 'path'; -import {createFilter} from 'rollup-pluginutils'; -import SVGO from 'svgo'; +const {extname} = require('path'); +const {createFilter} = require('rollup-pluginutils'); +const SVGO = require('svgo'); -import {svgOptions} from '@shopify/images/optimize'; +const {svgOptions} = require('@shopify/images/optimize'); const VIEWBOX_REGEX = /viewBox="([^"]*)"/; const SVG_REGEX = /(]*>|<\/svg>)/g; @@ -10,7 +10,7 @@ const FILL_REGEX = /fill="[^"]*"/g; const svgo = new SVGO(svgOptions()); -export default function icon(options = {}) { +module.exports = function icon(options = {}) { const filter = createFilter(options.include, options.exclude); return { @@ -41,4 +41,4 @@ export default function icon(options = {}) { }); }, }; -} +}; diff --git a/config/rollup/plugins/image.js b/config/rollup/plugins/image.js index a7f315dc8f4..08b6c58f1b3 100644 --- a/config/rollup/plugins/image.js +++ b/config/rollup/plugins/image.js @@ -1,6 +1,6 @@ -import {readFileSync} from 'fs'; -import {extname} from 'path'; -import {createFilter} from 'rollup-pluginutils'; +const {readFileSync} = require('fs'); +const {extname} = require('path'); +const {createFilter} = require('rollup-pluginutils'); const MIME_TYPES = { '.jpg': 'image/jpeg', @@ -10,7 +10,7 @@ const MIME_TYPES = { '.svg': 'image/svg+xml', }; -export default function image(options = {}) { +module.exports = function image(options = {}) { const filter = createFilter(options.include, options.exclude); return { @@ -30,4 +30,4 @@ export default function image(options = {}) { return `export default 'data:${mime};base64,${data}';`; }, }; -} +}; diff --git a/config/rollup/plugins/styles.js b/config/rollup/plugins/styles.js index ecbaa7290c2..694e72144ae 100644 --- a/config/rollup/plugins/styles.js +++ b/config/rollup/plugins/styles.js @@ -1,19 +1,19 @@ -import {resolve as resolvePath, dirname} from 'path'; -import postcss from 'postcss'; -import {readFileSync, ensureDirSync, writeFile} from 'fs-extra'; -import {render} from 'node-sass'; -import {createFilter} from 'rollup-pluginutils'; -import cssnano from 'cssnano'; - -import cssModulesExtractImports from 'postcss-modules-extract-imports'; -import cssModulesLocalByDefault from 'postcss-modules-local-by-default'; -import cssModulesScope from 'postcss-modules-scope'; -import cssModulesValues from 'postcss-modules-values'; -import Parser from 'postcss-modules-parser'; -import postcssShopify from 'postcss-shopify'; -import genericNames from 'generic-names'; - -export default function styles(options = {}) { +const {resolve: resolvePath, dirname} = require('path'); +const postcss = require('postcss'); +const {readFileSync, ensureDirSync, writeFile} = require('fs-extra'); +const {render} = require('node-sass'); +const {createFilter} = require('rollup-pluginutils'); +const cssnano = require('cssnano'); + +const cssModulesExtractImports = require('postcss-modules-extract-imports'); +const cssModulesLocalByDefault = require('postcss-modules-local-by-default'); +const cssModulesScope = require('postcss-modules-scope'); +const cssModulesValues = require('postcss-modules-values'); +const Parser = require('postcss-modules-parser'); +const postcssShopify = require('postcss-shopify'); +const genericNames = require('generic-names'); + +module.exports = function styles(options = {}) { const filter = createFilter( options.include || ['**/*.css', '**/*.scss'], options.exclude, @@ -127,7 +127,7 @@ export default function styles(options = {}) { ]); }, }; -} +}; function write(file, content) { return new Promise((resolve, reject) => { diff --git a/config/rollup/use-existing-classname-tokens.js b/config/rollup/use-existing-classname-tokens.js index f27586e4fbd..828122a8d48 100644 --- a/config/rollup/use-existing-classname-tokens.js +++ b/config/rollup/use-existing-classname-tokens.js @@ -1,5 +1,5 @@ -export default function createExistingClassnameTokensUser(tokens) { +module.exports = function createExistingClassnameTokensUser(tokens) { return function useExistingClassnameTokens(localName, filePath) { return tokens[filePath][localName]; }; -} +}; diff --git a/package.json b/package.json index 23fcd80b2a5..6e1c0f21cb5 100644 --- a/package.json +++ b/package.json @@ -42,16 +42,16 @@ "clean:build": "rimraf \"build/!(cache|coverage)\" build-esnext esnext styles types docs \"build-intermediate\" \"index.*\" \"./src/styles/polaris-tokens\" \"styles.{css,scss}\"", "optimize": "node ./scripts/optimize.js", "prebuild": "npm-run-all clean:build optimize copy-polaris-tokens", - "build": "babel-node ./scripts/build.js", + "build": "node ./scripts/build.js", "prebuild-consumer": "yarn run build", - "build-consumer": "babel-node ./scripts/build-consumer", + "build-consumer": "node ./scripts/build-consumer", "build-shrink-ray": "yarn run copy-polaris-tokens && node ./scripts/build-shrink-ray.js", "secrets": "ejson decrypt -o secrets.json secrets.ejson", "precdn": "yarn run build", "cdn:deploy": "node ./scripts/deploy.js", "cdn": "npm-run-all secrets cdn:deploy", "preopen-styleguide-pr": "rimraf sandbox && yarn run secrets", - "open-styleguide-pr": "babel-node ./scripts/open-styleguide-pr", + "open-styleguide-pr": "node ./scripts/open-styleguide-pr", "copy-polaris-tokens": "rimraf ./src/styles/polaris-tokens && shx cp -r ./node_modules/@shopify/polaris-tokens/dist ./src/styles/polaris-tokens", "prepublish": "in-publish && yarn run build || :", "postpublish": "in-publish && npm-run-all cdn open-styleguide-pr || :", @@ -60,7 +60,7 @@ "test:a11y": "yarn run storybook:build && node ./scripts/pa11y.js", "start": "start-storybook -p ${PORT} --ci --quiet", "heroku-postbuild": "yarn run copy-polaris-tokens", - "readme-update-version": "babel-node ./scripts/readme-update-version", + "readme-update-version": "node ./scripts/readme-update-version", "version": "yarn run readme-update-version", "storybook": "start-storybook -p 6006 --quiet", "storybook:build": "yarn run copy-polaris-tokens && build-storybook -o build/storybook/static" @@ -101,7 +101,6 @@ "@types/rollup": "0.51.4", "archiver": "^2.1.0", "aws-sdk": "^2.58.0", - "babel-cli": "^6.26.0", "babel-core": "^6.26.3", "babel-loader": "^7.1.5", "babel-preset-shopify": "^16.2.0", diff --git a/scripts/build-consumer.js b/scripts/build-consumer.js index ad1b675ce33..f0cd3a082df 100644 --- a/scripts/build-consumer.js +++ b/scripts/build-consumer.js @@ -1,9 +1,9 @@ /* eslint-disable no-console */ -import {resolve} from 'path'; -import {cp, mkdir, rm} from 'shelljs'; +const {resolve} = require('path'); +const {cp, mkdir, rm} = require('shelljs'); -import packageJSON from '../package.json'; +const packageJSON = require('../package.json'); const root = resolve(__dirname, '..'); const projectDir = process.argv[2]; diff --git a/scripts/build.js b/scripts/build.js index 67f083a6f78..3dc0c83cdc4 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,15 +1,15 @@ /* eslint-disable no-console */ -import {execSync} from 'child_process'; -import {join, resolve as resolvePath} from 'path'; -import {ensureDirSync, writeFileSync, readFileSync} from 'fs-extra'; -import {rollup} from 'rollup'; -import {cp, mv, rm} from 'shelljs'; -import copyfiles from 'copyfiles'; +const {execSync} = require('child_process'); +const {join, resolve: resolvePath} = require('path'); +const {ensureDirSync, writeFileSync, readFileSync} = require('fs-extra'); +const {rollup} = require('rollup'); +const {cp, mv, rm} = require('shelljs'); +const copyfiles = require('copyfiles'); -import createRollupConfig from '../config/rollup'; -import packageJSON from '../package.json'; -import generateSassBuild from './sass-build'; +const createRollupConfig = require('../config/rollup'); +const packageJSON = require('../package.json'); +const generateSassBuild = require('./sass-build'); const root = resolvePath(__dirname, '..'); const build = resolvePath(root, 'build'); diff --git a/scripts/open-styleguide-pr.js b/scripts/open-styleguide-pr.js index 5964c56edde..e6c1f25f46b 100644 --- a/scripts/open-styleguide-pr.js +++ b/scripts/open-styleguide-pr.js @@ -1,9 +1,9 @@ /* eslint-disable no-console */ -import {execSync} from 'child_process'; -import {resolve} from 'path'; -import {mkdir} from 'shelljs'; -import semver from 'semver'; +const {execSync} = require('child_process'); +const {resolve} = require('path'); +const {mkdir} = require('shelljs'); +const semver = require('semver'); const {version: packageVersion} = require('../package.json'); diff --git a/scripts/sass-build.js b/scripts/sass-build.js index 6816444cc17..157c845c94e 100644 --- a/scripts/sass-build.js +++ b/scripts/sass-build.js @@ -1,8 +1,8 @@ /* eslint-disable no-console */ -import {basename, resolve, join, relative} from 'path'; -import glob from 'glob'; -import { +const {basename, resolve, join, relative} = require('path'); +const glob = require('glob'); +const { writeFileSync, readFileSync, outputFileSync, @@ -10,16 +10,16 @@ import { createWriteStream, lstatSync, existsSync, -} from 'fs-extra'; -import {cp, mkdir} from 'shelljs'; -import archiver from 'archiver'; +} = require('fs-extra'); +const {cp, mkdir} = require('shelljs'); +const archiver = require('archiver'); const root = resolve(__dirname, '..'); const intermediateBuild = resolve(root, './build-intermediate'); const srcStyles = resolve(intermediateBuild, './styles'); const srcComponents = resolve(intermediateBuild, './components'); -export default function generateSassBuild(destinationDir) { +module.exports = function generateSassBuild(destinationDir) { const classnameTokens = readJSONSync(`${destinationDir}/polaris.tokens.json`); const buildSass = resolve(destinationDir, 'sass'); @@ -97,7 +97,7 @@ export default function generateSassBuild(destinationDir) { createSassIndex(components); return generateSassZip(buildSass, destinationDir); -} +}; // see https://archiverjs.com/docs/ function generateSassZip(sourceDir, destinationDir) { diff --git a/yarn.lock b/yarn.lock index 130377956ef..126e8b5a877 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2883,28 +2883,6 @@ axobject-query@^2.0.1: dependencies: ast-types-flow "0.0.7" -babel-cli@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" - integrity sha1-UCq1SHTX24itALiHoGODzgPQAvE= - dependencies: - babel-core "^6.26.0" - babel-polyfill "^6.26.0" - babel-register "^6.26.0" - babel-runtime "^6.26.0" - commander "^2.11.0" - convert-source-map "^1.5.0" - fs-readdir-recursive "^1.0.0" - glob "^7.1.2" - lodash "^4.17.4" - output-file-sync "^1.1.2" - path-is-absolute "^1.0.1" - slash "^1.0.0" - source-map "^0.5.6" - v8flags "^2.1.1" - optionalDependencies: - chokidar "^1.6.1" - babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -4994,22 +4972,6 @@ child-process-promise@^2.2.1: node-version "^1.0.0" promise-polyfill "^6.0.1" -chokidar@^1.6.1: - version "1.7.0" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" - integrity sha1-eY5ol3gVHIB2tLNg5e3SjNortGg= - dependencies: - anymatch "^1.3.0" - async-each "^1.0.0" - glob-parent "^2.0.0" - inherits "^2.0.1" - is-binary-path "^1.0.0" - is-glob "^2.0.0" - path-is-absolute "^1.0.0" - readdirp "^2.0.0" - optionalDependencies: - fsevents "^1.0.0" - chokidar@^2.0.0, chokidar@^2.0.2, chokidar@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.4.tgz#356ff4e2b0e8e43e322d18a372460bbcf3accd26" @@ -8316,11 +8278,6 @@ fs-minipass@^1.2.5: dependencies: minipass "^2.2.1" -fs-readdir-recursive@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" - integrity sha1-jNF0XItPiinIyuw5JHaSG6GV9WA= - fs-write-stream-atomic@^1.0.8: version "1.0.10" resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9" @@ -8336,7 +8293,7 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= -fsevents@^1.0.0, fsevents@^1.1.1, fsevents@^1.2.2: +fsevents@^1.1.1, fsevents@^1.2.2: version "1.2.4" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.4.tgz#f41dcb1af2582af3692da36fc55cbd8e1041c426" integrity sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg== @@ -8745,7 +8702,7 @@ got@^8.0.3, got@^8.3.1: url-parse-lax "^3.0.0" url-to-options "^1.0.1" -graceful-fs@^4.0.0, graceful-fs@^4.1.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6: +graceful-fs@^4.0.0, graceful-fs@^4.1.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= @@ -12969,15 +12926,6 @@ osenv@0, osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -output-file-sync@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" - integrity sha1-0KM+7+YaIF+suQCS6CZZjVJFznY= - dependencies: - graceful-fs "^4.1.4" - mkdirp "^0.5.1" - object-assign "^4.1.0" - p-any@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/p-any/-/p-any-1.1.0.tgz#1d03835c7eed1e34b8e539c47b7b60d0d015d4e1" @@ -17705,11 +17653,6 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -user-home@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" - integrity sha1-K1viOjK2Onyd640PKNSFcko98ZA= - util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -17755,13 +17698,6 @@ uuid@^3.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== -v8flags@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" - integrity sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ= - dependencies: - user-home "^1.1.1" - vali-date@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/vali-date/-/vali-date-1.0.0.tgz#1b904a59609fb328ef078138420934f6b86709a6"