Skip to content

Commit

Permalink
feat(build): generate ESM/CJS/UMD files with sourcemap for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed May 13, 2022
1 parent d5d443c commit 4ef4d04
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 deletions.
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
"name": "utm-synapse",
"version": "0.0.0-development",
"description": "Track and report UTM parameters along a browser session",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.mjs",
"unpkg": "./dist/umd/index.umd.js",
"jsdelivr": "./dist/umd/index.umd.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**/*"
],
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"clean": "rm -rf ./lib/",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:esm": "tsc -p tsconfig.build.json --outDir dist/esm",
"build:cjs": "tsc -p tsconfig.build.json --module commonjs --outDir dist/cjs",
"build:umd": "rollup dist/esm/index.js --format umd --name UtmSynapse --sourcemap --file dist/umd/index.js",
"build:umd:min": "uglifyjs --compress --mangle --source-map --comments -o dist/umd/index.min.js -- dist/umd/index.js",
"dev": "npm run clean && tsc -p tsconfig.build.json --outDir dist/esm --watch",
"clean": "rm -rf ./dist/",
"cm": "cz",
"coverage": "codecov",
"generate-docs": "typedoc",
Expand Down Expand Up @@ -67,6 +74,7 @@
"jest": "^27.2.0",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"rollup": "^2.72.1",
"semantic-release": "^19.0.2",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["src/**/*.spec.ts", "test/**/*.spec.ts"]
}
16 changes: 10 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
"target": "es2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "es2015" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"lib": [
"es2015",
"dom"
] /* Specify library files to be included in the compilation. */,
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
"declarationDir": "./dist/",
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"sourceMap": true /* Generates corresponding '.map' file. */,
// "outFile": "./", ÅÅÅ /* Concatenate and emit output to single file. */
"outDir": "./dist/" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
Expand Down Expand Up @@ -43,7 +47,7 @@
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
Expand Down

0 comments on commit 4ef4d04

Please sign in to comment.