Skip to content

Commit

Permalink
build: switch to webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker committed Sep 4, 2021
1 parent b12bc60 commit 6b8c9fd
Show file tree
Hide file tree
Showing 15 changed files with 2,660 additions and 40,600 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist/
lib/
node_modules/
jest.config.js
webpack.config.js
28 changes: 0 additions & 28 deletions __tests__/main.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ inputs:
description: Files to include in the release
runs:
using: 'node12'
main: 'dist/index.js'
main: 'dist/main.js'
37,185 changes: 0 additions & 37,185 deletions dist/index.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.js.map

This file was deleted.

1,430 changes: 0 additions & 1,430 deletions dist/licenses.txt

This file was deleted.

1 change: 1 addition & 0 deletions dist/main.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/sourcemap-register.js

This file was deleted.

9 changes: 0 additions & 9 deletions jest.config.js

This file was deleted.

24 changes: 10 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
"version": "0.0.0",
"private": true,
"description": "Generate automatic releases on new tag push",
"main": "lib/main.js",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
"build": "NODE_ENV=production webpack --config webpack.config.js",
"lint": "eslint --ignore-pattern .gitignore"
},
"repository": {
"type": "git",
Expand All @@ -29,23 +24,24 @@
"@actions/github": "^5.0.0",
"conventional-changelog-angular": "^5.0.12",
"conventional-commits-parser": "^3.2.1",
"globby": "^12.0.2",
"md5-file": "^5.0.0",
"semver": "^7.3.5"
"globby": "11.0.1",
"semver": "^7.3.5",
"terser-webpack-plugin": "4.2.3",
"ts-loader": "6.2.1",
"webpack": "4.41.4",
"webpack-cli": "3.3.10"
},
"devDependencies": {
"@types/node": "^16.3.3",
"@types/semver": "^7.3.8",
"@typescript-eslint/parser": "^4.28.3",
"@vercel/ncc": "^0.29.0",
"encoding": "^0.1.13",
"eslint": "^7.31.0",
"eslint-plugin-github": "^4.1.1",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.0.6",
"js-yaml": "^4.1.0",
"prettier": "2.2.1",
"ts-jest": "^27.0.3",
"typescript": "^4.1.3"
}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { main } from './main'
main()
6 changes: 2 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export const getChangelog = async (
return changelog;
};

async function run(): Promise<void> {
export async function main(): Promise<void> {
try {

const context = new Context();
Expand Down Expand Up @@ -261,12 +261,10 @@ async function run(): Promise<void> {
}
}

run();

export async function uploadReleaseArtifacts(client: InstanceType<typeof GitHub>, repo: string, owner: string, releaseId: number, files: string[]): Promise<void> {
core.startGroup("Uploading release artifacts")
for (let file of files) {
const paths = await globby.globby(file);
const paths = await globby(file);
if (paths.length === 0) {
core.warning(`${file} doesn't match any files`)
}
Expand Down
4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"compilerOptions": {
"moduleResolution": "Node",
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true ,
"lib": ["ES2020.String"]/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"exclude": ["node_modules", "**/*.test.ts"]
"exclude": ["node_modules"]
}
44 changes: 44 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const path = require('path')
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
mode: 'production',
target: "node",
entry: './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$/)],
}
Loading

0 comments on commit 6b8c9fd

Please sign in to comment.