Skip to content

Commit 45b0974

Browse files
build: add support ESM2015 and UMD builds
1 parent 4463f2e commit 45b0974

14 files changed

+260
-16
lines changed

.eslintrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ rules:
2222
'@typescript-eslint/no-inferrable-types': off
2323
'@typescript-eslint/no-explicit-any': off
2424
'@typescript-eslint/member-ordering': 'error'
25+
'@typescript-eslint/no-unused-vars':
26+
- 'error'
27+
- args: 'none'
2528
# TODO: Remove these and fixed issues once we merged all the current PRs.
2629
'@typescript-eslint/ban-types': off
2730
'@typescript-eslint/no-unsafe-return': off

.github/workflows/continuous-deployment-workflow.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
- run: npm run prettier:check
1717
- run: npm run lint:check
1818
- run: npm run test:ci
19-
- run: npm run build
19+
- run: npm run build:es2015
20+
- run: npm run build:esm5
21+
- run: npm run build:cjs
22+
- run: npm run build:umd
23+
- run: npm run build:types
2024
- run: cp LICENSE build/LICENSE
2125
- run: cp README.md build/README.md
2226
- run: jq 'del(.devDependencies) | del(.scripts)' package.json > build/package.json

.github/workflows/continuous-integration-workflow.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ jobs:
3838
- uses: actions/checkout@v1
3939
- uses: actions/setup-node@v1
4040
- run: npm ci --ignore-scripts
41-
- run: npm run build
41+
- run: npm run build:es2015
42+
- run: npm run build:esm5
43+
- run: npm run build:cjs
44+
- run: npm run build:umd
45+
- run: npm run build:types

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2015-2020 Umed Khudoiberdiev
3+
Copyright (c) 2015-2020 TypeStack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
44
collectCoverageFrom: ['src/**/*.ts', '!src/**/index.ts', '!src/**/*.interface.ts'],

package-lock.json

Lines changed: 168 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"name": "typedi",
33
"version": "0.8.0",
44
"description": "Dependency injection for TypeScript.",
5-
"private": true,
6-
"author": {
7-
"name": "Umed Khudoiberdiev",
8-
"email": "[email protected]"
9-
},
5+
"author": "TypeStack contributors",
6+
"license": "MIT",
7+
"sideEffects": false,
8+
"main": "./bundles/index.umd.js",
9+
"module": "./esm5/index.js",
10+
"es2015": "./esm2015/index.js",
11+
"typings": "./types/index.d.ts",
1012
"repository": {
1113
"type": "git",
1214
"url": "https://github.com/pleerock/typedi.git"
@@ -20,7 +22,13 @@
2022
"dependency-injection"
2123
],
2224
"scripts": {
23-
"build": "rimraf build && tsc --project tsconfig.prod.json",
25+
"build": "npm run build:cjs",
26+
"build:clean": "rimraf build",
27+
"build:es2015": "tsc --project tsconfig.prod.esm2015.json",
28+
"build:esm5": "tsc --project tsconfig.prod.esm5.json",
29+
"build:cjs": "tsc --project tsconfig.prod.cjs.json",
30+
"build:umd": "rollup --config rollup.config.js",
31+
"build:types": "tsc --project tsconfig.prod.types.json",
2432
"prettier:fix": "prettier --write \"**/*.{ts,md}\"",
2533
"prettier:check": "prettier --check \"**/*.{ts,md}\"",
2634
"lint:fix": "eslint --max-warnings 0 --fix --ext .ts src/",
@@ -43,6 +51,8 @@
4351
]
4452
},
4553
"devDependencies": {
54+
"@rollup/plugin-commonjs": "^14.0.0",
55+
"@rollup/plugin-node-resolve": "^8.4.0",
4656
"@types/jest": "^26.0.7",
4757
"@types/node": "^14.0.27",
4858
"@typescript-eslint/eslint-plugin": "^3.7.1",
@@ -56,6 +66,8 @@
5666
"prettier": "^2.0.5",
5767
"reflect-metadata": "0.1.13",
5868
"rimraf": "3.0.2",
69+
"rollup": "^2.23.1",
70+
"rollup-plugin-terser": "^6.1.0",
5971
"ts-jest": "^26.1.4",
6072
"ts-node": "^8.10.2",
6173
"typescript": "^3.9.7"

rollup.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { nodeResolve } from '@rollup/plugin-node-resolve';
2+
import commonjs from '@rollup/plugin-commonjs';
3+
import { terser } from 'rollup-plugin-terser';
4+
5+
export default {
6+
input: 'build/esm5/index.js',
7+
output: [
8+
{
9+
name: 'ClassTransformer',
10+
format: 'umd',
11+
file: 'build/bundles/typedi.umd.js',
12+
sourcemap: true,
13+
},
14+
{
15+
name: 'ClassTransformer',
16+
format: 'umd',
17+
file: 'build/bundles/typedi.umd.min.js',
18+
sourcemap: true,
19+
plugins: [terser()],
20+
},
21+
],
22+
plugins: [commonjs(), nodeResolve()],
23+
};

0 commit comments

Comments
 (0)