diff --git a/package-lock.json b/package-lock.json index 58a760e..b86075d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,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", @@ -11334,6 +11335,21 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rollup": { + "version": "2.72.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.72.1.tgz", + "integrity": "sha512-NTc5UGy/NWFGpSqF1lFY8z9Adri6uhyMLI6LvPAXdBKoPRFhIIiBUpt+Qg2awixqO3xvzSijjhnb4+QEZwJmxA==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -21685,6 +21701,15 @@ "glob": "^7.1.3" } }, + "rollup": { + "version": "2.72.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.72.1.tgz", + "integrity": "sha512-NTc5UGy/NWFGpSqF1lFY8z9Adri6uhyMLI6LvPAXdBKoPRFhIIiBUpt+Qg2awixqO3xvzSijjhnb4+QEZwJmxA==", + "dev": true, + "requires": { + "fsevents": "~2.3.2" + } + }, "run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", diff --git a/package.json b/package.json index ce2d160..128cb18 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..641219e --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["src/**/*.spec.ts", "test/**/*.spec.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 6b82dc0..899cf1f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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 */ @@ -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. */