diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 6700d36f..1cb1e78a 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-node@v1 with: - node-version: '10.x' + node-version: '12.x' registry-url: 'https://npm.pkg.github.com' - uses: actions/checkout@v2 - run: yarn install diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 417c12a7..04271ae7 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/setup-node@v1 with: - node-version: '10.x' + node-version: '12.x' registry-url: 'https://npm.pkg.github.com' - uses: actions/checkout@v2 - run: yarn install diff --git a/.tool-versions b/.tool-versions index d5c42e29..e21da253 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -nodejs 10.21.0 +nodejs 12.18.3 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index df7027e6..3ed68d63 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,7 +40,7 @@ These are the required software tools you need to install on your computer. ### Node.js -We are using [Node.js][node] v10.x. We recommend using a tool such as [asdf][asdf] +We are using [Node.js][node] v12.x. We recommend using a tool such as [asdf][asdf] or [nvm][nvm] if you need to install more than one version of Node.js. [node]: https://nodejs.org/en/ diff --git a/craco.config.js b/craco.config.js new file mode 100644 index 00000000..9d2219c9 --- /dev/null +++ b/craco.config.js @@ -0,0 +1,54 @@ +// https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#configuration + +const { getLoader, getLoaders, loaderByName } = require('@craco/craco'); + +module.exports = { + webpack: { + configure: { + resolve: { + // need 'esnext' first to avoid compile errors + mainFields: ['esnext', 'browser', 'module', 'main'], + }, + }, + }, + plugins: [ + { + plugin: { + overrideWebpackConfig: ({ + webpackConfig, + cracoConfig, + pluginOptions, + context: { env, paths }, + }) => { + // add .esnext file extension for @shopify/* + + webpackConfig.resolve.extensions = [ + '.web.esnext', + '.esnext', + ...webpackConfig.resolve.extensions, + ]; + + const babelLoaders = getLoaders( + webpackConfig, + loaderByName('babel-loader'), + ); + babelLoaders.matches[0].loader.test = /\.(esnext|js|mjs|jsx|ts|tsx)$/; + babelLoaders.matches[1].loader.test = /\.(esnext|js|mjs)$/; + + const fileLoader = getLoader( + webpackConfig, + loaderByName('file-loader'), + ); + fileLoader.match.loader.exclude = [ + /\.(esnext|js|mjs|jsx|ts|tsx)$/, + /\.html$/, + /\.json$/, + ]; + + return webpackConfig; + }, + }, + options: {}, + }, + ], +}; diff --git a/package.json b/package.json index 3efaf11f..2616b809 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "private": true, "dependencies": { "@blueprintjs/core": "^3.36.0", + "@craco/craco": "^6.0.0", "@pybricks/firmware": "4.3.0", "@pybricks/mpy-cross-v5": "^1.1.0", - "@shopify/react-i18n": "^5.0.0", + "@shopify/react-i18n": "^5.2.0", "@testing-library/dom": "^7.29.2", "@testing-library/jest-dom": "^5.11.8", "@testing-library/react": "^11.2.3", @@ -43,10 +44,10 @@ }, "scripts": { "prepare": "mkdirp public/static/js && ncp node_modules/@pybricks/mpy-cross-v5/build/mpy-cross.wasm src/sagas/mpy-cross.emcwasm", - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test --env=./test/env.js", - "coverage": "react-scripts test --env=./test/env.js --coverage --watchAll=false", + "start": "craco start", + "build": "craco build", + "test": "craco test --env=./test/env.js", + "coverage": "craco test --env=./test/env.js --coverage --watchAll=false", "coverage:html": "yarn coverage --coverageReporters html", "eject": "react-scripts eject", "lint": "tsc --noEmit && eslint \"*/**/*.{js,ts,tsx}\" --quiet --fix" diff --git a/src/components/ActionButton.tsx b/src/components/ActionButton.tsx index 3f7a9c13..23aad054 100644 --- a/src/components/ActionButton.tsx +++ b/src/components/ActionButton.tsx @@ -1,9 +1,15 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors -import { Button, Hotkey, Hotkeys, Intent, Position, Tooltip } from '@blueprintjs/core'; -// importing this way due to https://github.com/palantir/blueprint/issues/3604 -import { HotkeysTarget } from '@blueprintjs/core/lib/esnext/components/hotkeys/hotkeysTarget'; +import { + Button, + Hotkey, + Hotkeys, + HotkeysTarget, + Intent, + Position, + Tooltip, +} from '@blueprintjs/core'; import { WithI18nProps, withI18n } from '@shopify/react-i18n'; import React from 'react'; import { TooltipId } from './button-i18n'; diff --git a/src/components/Editor.tsx b/src/components/Editor.tsx index 957d99db..9bf4d335 100644 --- a/src/components/Editor.tsx +++ b/src/components/Editor.tsx @@ -1,9 +1,13 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors -import { Menu, MenuDivider, MenuItem, ResizeSensor } from '@blueprintjs/core'; -// importing this way due to https://github.com/palantir/blueprint/issues/3891 -import { ContextMenuTarget } from '@blueprintjs/core/lib/esnext/components/context-menu/contextMenuTarget'; +import { + ContextMenuTarget, + Menu, + MenuDivider, + MenuItem, + ResizeSensor, +} from '@blueprintjs/core'; import { WithI18nProps, withI18n } from '@shopify/react-i18n'; import { Ace, config } from 'ace-builds'; import React from 'react'; diff --git a/src/components/Terminal.tsx b/src/components/Terminal.tsx index 94afad60..315bd848 100644 --- a/src/components/Terminal.tsx +++ b/src/components/Terminal.tsx @@ -1,9 +1,13 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors -import { Menu, MenuDivider, MenuItem, ResizeSensor } from '@blueprintjs/core'; -// importing this way due to https://github.com/palantir/blueprint/issues/3891 -import { ContextMenuTarget } from '@blueprintjs/core/lib/esnext/components/context-menu/contextMenuTarget'; +import { + ContextMenuTarget, + Menu, + MenuDivider, + MenuItem, + ResizeSensor, +} from '@blueprintjs/core'; import { WithI18nProps, withI18n } from '@shopify/react-i18n'; import React from 'react'; import { connect } from 'react-redux'; diff --git a/yarn.lock b/yarn.lock index 7e7af3ad..52db7021 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1163,6 +1163,16 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@craco/craco@^6.0.0": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@craco/craco/-/craco-6.0.0.tgz#f4e66e82f5bc77671dc0a5e839c3269e2414fe0f" + integrity sha512-NSgcGqTlQ+XTBJ/AhE0ngdfab5xIyx/06yrRPkvDH02V90ejrL6bSM54k3+h3OjGE/SO7nmF1MqfFwemPo8kVw== + dependencies: + cross-spawn "^7.0.0" + lodash "^4.17.15" + semver "^7.3.2" + webpack-merge "^4.2.2" + "@csstools/convert-colors@^1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7" @@ -1558,62 +1568,62 @@ estree-walker "^1.0.1" picomatch "^2.2.2" -"@shopify/dates@^0.4.3": - version "0.4.3" - resolved "https://registry.yarnpkg.com/@shopify/dates/-/dates-0.4.3.tgz#6b068b25db419b0911f95890c153082844bbb89a" - integrity sha512-wL8dzk9u9o0H8AKiqQSIqLD77ww2mPtLAC8HiVb+I+sYEW8hoLmqW0JGAIcBgdL4Pyybc6XSQwvdfQM27XvP0g== +"@shopify/dates@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@shopify/dates/-/dates-0.5.0.tgz#a3a28bcc381ecb04b2251e832af16503f6b7e2c4" + integrity sha512-oDEyuqeVqFljPRAcbQlaEZ08j2oBN3OGVtG905MYhgQ4GUMTnCkp5jMXEqRxmawwuYGmnaeyQMMsDF4bUoajDg== dependencies: - "@shopify/decorators" "^1.1.13" + "@shopify/decorators" "^1.2.0" tslib "^1.14.1" -"@shopify/decorators@^1.1.13": - version "1.1.13" - resolved "https://registry.yarnpkg.com/@shopify/decorators/-/decorators-1.1.13.tgz#61efc503d3ea068fd47f83d33d152bf554ee4efe" - integrity sha512-Ky99a1jv0xc9kYLlK/wYD+1LrdcjL0uFSUn6ZnJplXoCdm/5lv+d4h6A3w2wSlNgS0hIWnx480sFjKmkzRoORg== +"@shopify/decorators@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@shopify/decorators/-/decorators-1.2.0.tgz#8d464d2378a2cb768fc57b5a9fc826d0d859d153" + integrity sha512-KjiE612ErFcZQ40TMQJVo/LLcjuU+BQT/vRJrZVJlxLXAjxzmwRd3oCL7KMQrpDCfDWGr2b3OigK3ldXWoh+vA== dependencies: - "@shopify/function-enhancers" "^1.0.11" + "@shopify/function-enhancers" "^1.1.0" tslib "^1.14.1" -"@shopify/function-enhancers@^1.0.11": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@shopify/function-enhancers/-/function-enhancers-1.0.11.tgz#5ea80d055aa61618cda40c215c424a3b053f2c4e" - integrity sha512-VMV5iReVL2CHrqLGMmJg5eueiFySiiSx3plU2/IywjaOMi2bDQFo+juRXYuPtBloclKuwHoc4L7BGliQGH8zaA== +"@shopify/function-enhancers@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@shopify/function-enhancers/-/function-enhancers-1.1.0.tgz#3c42b78edd59f8cb6fe85408ca39fc92f3e5dad3" + integrity sha512-wIrGDa5aRiOr8E3JT3+8svkBskFE7NjGCzLo/Tu7SA5t5spgxTqF85J/ilbSPFnOsvBO/teeDIVKClFtGSlkhw== dependencies: tslib "^1.14.1" -"@shopify/i18n@^0.1.12": - version "0.1.12" - resolved "https://registry.yarnpkg.com/@shopify/i18n/-/i18n-0.1.12.tgz#e4bb51f0b0eb1a15c1924c64d83f92a8e17dbdff" - integrity sha512-EgXkE9kNhGlSuo7s5sEivRuFg3TfnDyMVjOXexAfCInF9Grwm5hhpCriMdbxYz/GkSlODp9cETTebyVGL0IM9A== +"@shopify/i18n@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@shopify/i18n/-/i18n-0.2.0.tgz#9d892b2bbb1ac519345a5eede43f0d030aa0bf0f" + integrity sha512-nWXLEhu1/nCoyuz9itx79R+yrVjU6a+Zbsm7FYP1koSSTaQEKMOPwdfEgtB2y65/PKmjmXwg3p+TIMHONzVI2g== dependencies: tslib "^1.14.1" -"@shopify/react-effect@^3.2.13": - version "3.2.13" - resolved "https://registry.yarnpkg.com/@shopify/react-effect/-/react-effect-3.2.13.tgz#95ff8ff089ceee049941001cd1a9a1c3627ef63f" - integrity sha512-KzRpKUzrATwrNMb+JrYWI52j6UDGFcGYDe+bXr8XQxJaU8H8umxn5t9zk4OLUoMf1yoUn98OrAShDsg6ZayI3g== +"@shopify/react-effect@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@shopify/react-effect/-/react-effect-3.3.0.tgz#9538ee55e5e9b20831a70744071be17d2b317228" + integrity sha512-Mnm/CXLY2/1Vc3or9KMJYrdK3nDmxZx/l1oc1u3bbtB8HhkUcbQWjxBip5dyNBv6R5Gp42Cg28q+F+fn7Sziww== dependencies: tslib "^1.14.1" -"@shopify/react-hooks@^1.11.2": - version "1.11.2" - resolved "https://registry.yarnpkg.com/@shopify/react-hooks/-/react-hooks-1.11.2.tgz#216421d52abc94c5c8e5b8821ff7800da6949110" - integrity sha512-KVbBxdOXcShtj+PJrfq5FW0T6DkqXkt3Q4YKf3NlGrBB0vprrN71Zs4MAyUhCqJp1B7qfKM8dgHcikmIxtDp4Q== +"@shopify/react-hooks@^1.12.0": + version "1.12.0" + resolved "https://registry.yarnpkg.com/@shopify/react-hooks/-/react-hooks-1.12.0.tgz#b31e7eb3c1a1eaa8f20a1473b0def619f90cb462" + integrity sha512-j8c9J0alSt0/NcuPg1K5L57GO8rYfbskulqFrsCv4gCYVgEVPyJd3DqKaErxcY9kYzDEKfEDI2+hIAiR3Uiqsw== dependencies: tslib "^1.14.1" -"@shopify/react-i18n@^5.0.0": - version "5.1.4" - resolved "https://registry.yarnpkg.com/@shopify/react-i18n/-/react-i18n-5.1.4.tgz#fd3c7f9246540a6f0955952a8da4e7d3c5f0aa23" - integrity sha512-wtNJurv2CaahHv14VxlLTiFwRMwmdQ07QwtKePGngVr4WDwmNYRTbknV4UP/S+x7TgozVFjhRKp5T/4rUI4EnQ== +"@shopify/react-i18n@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@shopify/react-i18n/-/react-i18n-5.2.0.tgz#2612296e2df6af95e4616f9358daa04084f49b00" + integrity sha512-l4TZ1A5x+zAuv1ytkJOmdRZ+tIRBxyzkpdacaYrleVJjmgCERHwuE5DMfM0WnyMzngUhd3BPAY0iC2LGqcN+uw== dependencies: - "@shopify/dates" "^0.4.3" - "@shopify/decorators" "^1.1.13" - "@shopify/function-enhancers" "^1.0.11" - "@shopify/i18n" "^0.1.12" - "@shopify/react-effect" "^3.2.13" - "@shopify/react-hooks" "^1.11.2" - "@shopify/useful-types" "^2.2.1" + "@shopify/dates" "^0.5.0" + "@shopify/decorators" "^1.2.0" + "@shopify/function-enhancers" "^1.1.0" + "@shopify/i18n" "^0.2.0" + "@shopify/react-effect" "^3.3.0" + "@shopify/react-hooks" "^1.12.0" + "@shopify/useful-types" "^2.3.0" "@types/hoist-non-react-statics" "^3.0.1" change-case "^3.1.0" glob "^7.1.4" @@ -1627,10 +1637,10 @@ "@babel/traverse" "^7.0.0" fs-extra "^8.1.0" -"@shopify/useful-types@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@shopify/useful-types/-/useful-types-2.2.1.tgz#187fe009123e560e2eed6f4d375fb53248a33b0d" - integrity sha512-I0mZqYHjZY4+CONy0z+awtpKDY3E6OcnSnMAmMuEANCgNow86vtB4cYJb/udJX+znNj7yKfzdp3iG531lD7aFA== +"@shopify/useful-types@^2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@shopify/useful-types/-/useful-types-2.3.0.tgz#d14376eb9da2c45ffbb3849cb3be2da98c7ef1c0" + integrity sha512-T5FuS/hNFTxS18kpB3Z8fTwaM0q7fkXPpZLpV6fug5pHw1dFiuCTvidBUDALJJyCRJ5mONQc2m2bQt8MGvn90A== dependencies: tslib "^1.14.1" @@ -12475,6 +12485,13 @@ webpack-manifest-plugin@2.2.0: object.entries "^1.1.0" tapable "^1.0.0" +webpack-merge@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" + integrity sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g== + dependencies: + lodash "^4.17.15" + webpack-sources@^1.1.0, webpack-sources@^1.3.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"