From 6f6b6938dd13479c6de2238317265664d172a0ed Mon Sep 17 00:00:00 2001 From: cpojer Date: Sat, 2 May 2020 00:32:19 +0100 Subject: [PATCH] Remove es5 builds --- .circleci/config.yml | 12 ---- .eslintignore | 1 - .eslintrc.js | 1 - .github/workflows/nodejs.yml | 2 - .gitignore | 1 - CHANGELOG.md | 2 + e2e/browser-support/browserTest.js | 28 ---------- jest.config.js | 2 - karma.conf.js | 25 --------- package.json | 7 --- packages/expect/package.json | 1 - packages/jest-mock/package.json | 1 - packages/pretty-format/package.json | 1 - scripts/browserBuild.js | 87 ----------------------------- scripts/build.js | 39 ------------- tsconfig.json | 3 +- 16 files changed, 3 insertions(+), 210 deletions(-) delete mode 100644 e2e/browser-support/browserTest.js delete mode 100644 karma.conf.js delete mode 100644 scripts/browserBuild.js diff --git a/.circleci/config.yml b/.circleci/config.yml index 578043e864e6..404054466e1a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -104,17 +104,6 @@ jobs: - store_test_results: path: reports/junit - test-browser: - working_directory: ~/jest - docker: - - image: circleci/node:12-browsers - steps: - - checkout - - restore-cache: *restore-cache - - run: *install - - save-cache: *save-cache - - run: yarn test-ci-es5-build-in-browser - test-or-deploy-website: working_directory: ~/jest docker: @@ -140,6 +129,5 @@ workflows: - test-node-13 - test-node-14 # current - test-jest-circus - - test-browser - test-or-deploy-website: filters: *filter-ignore-gh-pages diff --git a/.eslintignore b/.eslintignore index 05311c4695d6..be8072a6a850 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,7 +3,6 @@ bin/ flow-typed/** packages/*/build/** -packages/*/build-es5/** packages/jest-diff/src/cleanupSemantic.ts website/blog website/build diff --git a/.eslintrc.js b/.eslintrc.js index 3594b3b18ec6..b72d563d7295 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -95,7 +95,6 @@ module.exports = { files: [ 'packages/jest-jasmine2/src/jasmine/**/*', 'packages/expect/src/jasmineUtils.ts', - 'e2e/browser-support/browserTest.js', '**/vendor/**/*', ], rules: { diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 78c1927a0e6f..5df30a9d3bc7 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -45,8 +45,6 @@ jobs: run: yarn verify-old-ts - name: run eslint run: yarn lint - - name: run eslint on browser builds - run: yarn lint-es5-build - name: run prettier run: yarn lint:prettier:ci - name: check copyright headers diff --git a/.gitignore b/.gitignore index 36a8de27bd81..c6b727d6dfa1 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ /node_modules /packages/*/build/ -/packages/*/build-es5/ /packages/*/coverage/ /packages/*/node_modules/ /packages/*/package-lock.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b9b4387f3f..d738e9188d90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ### Chore & Maintenance +- `[expect, jest-mock, pretty-format]` [**BREAKING**] Remove `build-es5` from package ([#9945](https://github.com/facebook/jest/pull/9945)) + ### Performance ## 25.5.3 diff --git a/e2e/browser-support/browserTest.js b/e2e/browser-support/browserTest.js deleted file mode 100644 index 2fbeae3d08c0..000000000000 --- a/e2e/browser-support/browserTest.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* eslint-disable */ -var expect = require('expect'); -var mock = require('jest-mock'); -var prettyFormat = require('pretty-format'); - -describe('es5 builds in browser', function() { - it('runs assertions', function() { - expect(1).toBe(1); - }); - - it('runs mocks', function() { - var someMockFunction = mock.fn(); - expect(someMockFunction).not.toHaveBeenCalled(); - someMockFunction(); - expect(someMockFunction).toHaveBeenCalledTimes(1); - }); - - it('pretty formats a string', function() { - expect(prettyFormat('obj')).toBe('"obj"'); - }); -}); diff --git a/jest.config.js b/jest.config.js index cb189da42604..18ad91a82b6d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -23,7 +23,6 @@ module.exports = { modulePathIgnorePatterns: [ 'examples/.*', 'packages/.*/build', - 'packages/.*/build-es5', 'packages/jest-runtime/src/__tests__/test_root.*', 'website/.*', 'e2e/runtime-internal-module-registry/__mocks__', @@ -44,7 +43,6 @@ module.exports = { '/e2e/global-teardown', '\\.snap$', '/packages/.*/build', - '/packages/.*/build-es5', '/packages/.*/src/__tests__/setPrettyPrint.ts', '/packages/jest-core/src/__tests__/test_root', '/packages/jest-core/src/__tests__/__fixtures__/', diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 61e032d44fa7..000000000000 --- a/karma.conf.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -module.exports = config => { - config.set({ - browsers: ['ChromeHeadless'], - files: ['e2e/browser-support/browserTest.js'], - frameworks: ['mocha'], - preprocessors: { - 'e2e/browser-support/browserTest.js': ['webpack'], - }, - webpack: { - mode: 'development', - }, - webpackMiddleware: { - // webpack-dev-middleware configuration - // i. e. - stats: 'errors-only', - }, - }); -}; diff --git a/package.json b/package.json index 338d2679d898..e560e0355b7e 100644 --- a/package.json +++ b/package.json @@ -59,10 +59,6 @@ "jest-snapshot-serializer-raw": "^1.1.0", "jest-watch-typeahead": "^0.5.0", "jquery": "^3.2.1", - "karma": "^4.0.1", - "karma-chrome-launcher": "^3.0.0", - "karma-mocha": "^1.3.0", - "karma-webpack": "^4.0.2", "lerna": "^3.20.2", "make-dir": "^3.0.0", "micromatch": "^4.0.2", @@ -82,7 +78,6 @@ "tempy": "~0.3.0", "throat": "^5.0.0", "typescript": "^3.8.2", - "webpack": "^4.28.4", "which": "^2.0.1" }, "scripts": { @@ -96,14 +91,12 @@ "jest": "node ./packages/jest-cli/bin/jest.js", "jest-coverage": "yarn jest --coverage", "lint": "eslint . --cache --ext js,jsx,ts,tsx,md", - "lint-es5-build": "eslint --no-eslintrc --no-ignore --env=browser packages/*/build-es5", "lint:prettier": "prettier '**/*.{md,yml,yaml}' 'website/static/**/*.{css,js}' --write --ignore-path .gitignore", "lint:prettier:ci": "prettier '**/*.{md,yml,yaml}' 'website/static/**/*.{css,js}' --check --ignore-path .gitignore", "postinstall": "opencollective postinstall && yarn build", "install-no-ts-build": "node ./scripts/remove-postinstall && yarn --no-progress --frozen-lockfile && node ./scripts/build", "remove-prettier-dep": "node ./scripts/remove-prettier-dep", "publish": "yarn build-clean && yarn build && lerna publish --silent", - "test-ci-es5-build-in-browser": "karma start --single-run", "test-ci": "yarn jest-coverage --color -i --config jest.config.ci.js && yarn test-leak && node ./scripts/mapCoverage.js && codecov", "test-ci-partial": "yarn jest --color -i --config jest.config.ci.js", "test-pretty-format-perf": "node packages/pretty-format/perf/test.js", diff --git a/packages/expect/package.json b/packages/expect/package.json index df859e2e4715..18101b026061 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -16,7 +16,6 @@ ] } }, - "browser": "build-es5/index.js", "dependencies": { "@jest/types": "^25.5.0", "ansi-styles": "^4.0.0", diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index 775cc56c409d..33e5455da8ac 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -25,7 +25,6 @@ ] } }, - "browser": "build-es5/index.js", "publishConfig": { "access": "public" }, diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index dedbfab6721a..66ea7d8b2c16 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -17,7 +17,6 @@ ] } }, - "browser": "build-es5/index.js", "author": "James Kyle ", "dependencies": { "@jest/types": "^25.5.0", diff --git a/scripts/browserBuild.js b/scripts/browserBuild.js deleted file mode 100644 index 6e35147a9dd6..000000000000 --- a/scripts/browserBuild.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -'use strict'; - -const path = require('path'); -const webpack = require('webpack'); -const camelCase = require('camelcase'); -const rimraf = require('rimraf'); - -const transformOptions = require('../babel.config.js'); - -const babelEs5Options = { - // Dont load other config files - babelrc: false, - configFile: false, - overrides: transformOptions.overrides, - plugins: ['@babel/plugin-transform-strict-mode'], - presets: [ - [ - '@babel/preset-env', - { - // Required for Webpack - modules: 'cjs', - shippedProposals: true, - // Target ES5 - targets: 'IE 11', - }, - ], - ], -}; - -function browserBuild(pkgName, entryPath, destination) { - rimraf.sync(destination); - - return new Promise((resolve, reject) => { - webpack( - /* eslint-disable sort-keys */ - { - mode: 'development', - devtool: 'source-map', - entry: entryPath, - output: { - path: path.dirname(destination), - library: camelCase(pkgName), - libraryTarget: 'umd', - filename: path.basename(destination), - }, - module: { - rules: [ - { - test: /\.[jt]sx?$/, - loader: require.resolve('babel-loader'), - options: babelEs5Options, - }, - ], - }, - resolve: { - alias: { - chalk: path.resolve( - __dirname, - '../packages/expect/build/fakeChalk.js', - ), - 'graceful-fs': 'fs', - }, - extensions: ['.js', '.json', '.ts'], - }, - node: { - fs: 'empty', - }, - }, - /* eslint-enable */ - (err, stats) => { - if (err || stats.hasErrors()) { - reject(err || stats.toString()); - return; - } - resolve(stats); - }, - ); - }); -} - -module.exports = browserBuild; diff --git a/scripts/build.js b/scripts/build.js index 7c5e0f5c3ba7..d6d718cbe322 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -30,11 +30,9 @@ const chalk = require('chalk'); const micromatch = require('micromatch'); const prettier = require('prettier'); const {getPackages, adjustToTerminalWidth, OK} = require('./buildUtils'); -const browserBuild = require('./browserBuild'); const SRC_DIR = 'src'; const BUILD_DIR = 'build'; -const BUILD_ES5_DIR = 'build-es5'; const JS_FILES_PATTERN = '**/*.js'; const TS_FILES_PATTERN = '**/*.ts'; const IGNORE_PATTERN = '**/__{tests,mocks}__/**'; @@ -72,39 +70,6 @@ function buildNodePackage(p) { process.stdout.write(`${OK}\n`); } -function buildBrowserPackage(p) { - const srcDir = path.resolve(p, SRC_DIR); - const pkgJsonPath = path.resolve(p, 'package.json'); - - if (!fs.existsSync(pkgJsonPath)) { - return; - } - - const browser = require(pkgJsonPath).browser; - if (browser) { - if (browser.indexOf(BUILD_ES5_DIR) !== 0) { - throw new Error( - `browser field for ${pkgJsonPath} should start with "${BUILD_ES5_DIR}"`, - ); - } - let indexFile = path.resolve(srcDir, 'index.js'); - - if (!fs.existsSync(indexFile)) { - indexFile = indexFile.replace(/\.js$/, '.ts'); - } - - browserBuild(p.split('/').pop(), indexFile, path.resolve(p, browser)) - .then(() => { - process.stdout.write(adjustToTerminalWidth(`${path.basename(p)}\n`)); - process.stdout.write(`${OK}\n`); - }) - .catch(e => { - console.error(e); - process.exit(1); - }); - } -} - function buildFile(file, silent) { const destPath = getBuildPath(file, BUILD_DIR); @@ -187,8 +152,4 @@ if (files.length) { const packages = getPackages(); process.stdout.write(chalk.inverse(' Building packages \n')); packages.forEach(buildNodePackage); - process.stdout.write('\n'); - - process.stdout.write(chalk.inverse(' Building browser packages \n')); - packages.forEach(buildBrowserPackage); } diff --git a/tsconfig.json b/tsconfig.json index a513c83fe2c2..b1d9bfdd5414 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,7 +29,6 @@ ".yarn/releases/*", "**/__tests__/**/*", "**/__mocks__/**/*", - "**/build/**/*", - "**/build-es5/**/*" + "**/build/**/*" ] }