From 04987857e76f3b1469cac73252ea68b4a2a22c87 Mon Sep 17 00:00:00 2001 From: Marvin Pinto Date: Thu, 26 Dec 2019 21:04:30 -0500 Subject: [PATCH] build: switch automatic-releases over to using webpack as the bundler --- package.json | 1 - .../__tests__/taggedReleases-smoke.test.ts | 4 +- packages/automatic-releases/package.json | 6 ++- packages/automatic-releases/src/utils.ts | 4 +- packages/automatic-releases/webpack.config.js | 52 +++++++++++++++++++ yarn.lock | 5 -- 6 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 packages/automatic-releases/webpack.config.js diff --git a/package.json b/package.json index 2c720a12..42e94829 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "@types/node": "^13.1.0", "@typescript-eslint/eslint-plugin": "^2.13.0", "@typescript-eslint/parser": "^2.13.0", - "@zeit/ncc": "^0.20.5", "eslint": "^6.8.0", "eslint-config-prettier": "^6.8.0", "eslint-plugin-jest": "^23.1.1", diff --git a/packages/automatic-releases/__tests__/taggedReleases-smoke.test.ts b/packages/automatic-releases/__tests__/taggedReleases-smoke.test.ts index 9238f054..d465de30 100644 --- a/packages/automatic-releases/__tests__/taggedReleases-smoke.test.ts +++ b/packages/automatic-releases/__tests__/taggedReleases-smoke.test.ts @@ -36,8 +36,8 @@ describe('tagged releases smoke tests', () => { }, }); - // Should set the AUTOMATIC_RELEASES_TAG env variable to "testingtaglatest" - expect(stdout).toEqual(expect.stringMatching(/::set-env name=AUTOMATIC_RELEASES_TAG,::testingtaglatest/)); + // Should set the AUTOMATIC_RELEASES_TAG env variable to "v0.0.1" + expect(stdout).toEqual(expect.stringMatching(/::set-env name=AUTOMATIC_RELEASES_TAG,::v0.0.1/)); // There should not be any stderr output expect(stderr).toEqual(''); diff --git a/packages/automatic-releases/package.json b/packages/automatic-releases/package.json index 53cfbf2e..5918087b 100644 --- a/packages/automatic-releases/package.json +++ b/packages/automatic-releases/package.json @@ -10,7 +10,7 @@ "prettierPaths": "**/*.{json,md,yaml,yml} !package.json" }, "scripts": { - "build": "ncc build src/index.ts", + "build": "webpack --config webpack.config.js --colors", "test": "jest --color --forceExit", "clean": "rm -rf node_modules yarn-error.log dist", "lint": "yarn run lint:eslint && yarn run lint:prettier", @@ -34,6 +34,10 @@ "express": "^4.17.1", "nock": "^11.7.0", "portfinder": "^1.0.25", + "terser-webpack-plugin": "^2.3.1", + "ts-loader": "^6.2.1", + "webpack": "^4.41.4", + "webpack-cli": "^3.3.10", "which": "^2.0.2" }, "eslintIgnore": [ diff --git a/packages/automatic-releases/src/utils.ts b/packages/automatic-releases/src/utils.ts index 665a4559..a56bc84a 100644 --- a/packages/automatic-releases/src/utils.ts +++ b/packages/automatic-releases/src/utils.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core'; import * as Octokit from '@octokit/rest'; -import defaultChangelogOpts from 'conventional-changelog-angular'; +import defaultChangelogOpts from 'conventional-changelog-angular/conventional-recommended-bump'; export const getShortSHA = (sha: string): string => { const coreAbbrev = 7; @@ -157,7 +157,7 @@ export const parseGitTag = (inputRef): string => { }; export const getChangelogOptions = async () => { - const defaultOpts = await defaultChangelogOpts; + const defaultOpts = defaultChangelogOpts; defaultOpts['mergePattern'] = '^Merge pull request #(.*) from (.*)$'; defaultOpts['mergeCorrespondence'] = ['issueId', 'source']; core.debug(`Changelog options: ${JSON.stringify(defaultOpts)}`); diff --git a/packages/automatic-releases/webpack.config.js b/packages/automatic-releases/webpack.config.js new file mode 100644 index 00000000..adaa3056 --- /dev/null +++ b/packages/automatic-releases/webpack.config.js @@ -0,0 +1,52 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const path = require('path'); +const webpack = require('webpack'); +const TerserPlugin = require('terser-webpack-plugin'); + +module.exports = { + target: 'node', + mode: 'production', + + entry: { + index: './src/index.ts', + }, + + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + ], + }, + + resolve: { + extensions: ['.tsx', '.ts', '.js'], + mainFields: ['main'], + }, + + output: { + filename: '[name].js', + path: path.resolve(__dirname, 'dist'), + library: 'main', + libraryTarget: 'commonjs2', + }, + + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + terserOptions: { + output: { + comments: false, + }, + }, + sourceMap: true, + extractComments: false, + }), + ], + }, + + plugins: [new webpack.IgnorePlugin(/\/iconv-loader$/)], +}; diff --git a/yarn.lock b/yarn.lock index d2103b5f..c606e0f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1648,11 +1648,6 @@ resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== -"@zeit/ncc@^0.20.5": - version "0.20.5" - resolved "https://registry.yarnpkg.com/@zeit/ncc/-/ncc-0.20.5.tgz#a41af6e6bcab4a58f4612bae6137f70bce0192e3" - integrity sha512-XU6uzwvv95DqxciQx+aOLhbyBx/13ky+RK1y88Age9Du3BlA4mMPCy13BGjayOrrumOzlq1XV3SD/BWiZENXlw== - "@zkochan/cmd-shim@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@zkochan/cmd-shim/-/cmd-shim-3.1.0.tgz#2ab8ed81f5bb5452a85f25758eb9b8681982fd2e"