diff --git a/package.json b/package.json index 73899c3..dedc643 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "types": "index.d.ts", "engines": {"node": "^18 || ^20"}, "scripts": { - "test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -r ts-node/register tests/**/*.test.ts", - "build": "tsc", + "test": "TS_NODE_PROJECT=tsconfig.cjs.json mocha -r ts-node/register tests/**/*.test.ts", + "build": "tsc -p tsconfig.cjs.json", "prepare": "husky", "precommit": "lint-staged", "lint": "eslint src", diff --git a/rollup.config.mjs b/rollup.config.mjs index 12dcdc3..6b7d268 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,20 +1,26 @@ -import typescript from '@rollup/plugin-typescript'; -import nodePolyfills from 'rollup-plugin-polyfill-node'; -import { nodeResolve } from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; +import typescript from "@rollup/plugin-typescript"; +import nodePolyfills from "rollup-plugin-polyfill-node"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; export default { - input: "src/index.ts", - output: { - dir: "out", - format: 'umd', - name: 'lightningflowscanner', - sourcemap: true, - globals: { - "path-browserify": "p", - xmlbuilder2: "xmlbuilder2" - } - }, - plugins: [nodePolyfills(), typescript(), nodeResolve({preferBuiltins:true}), nodePolyfills()], - external: ["path-browserify", "xmlbuilder2"] -} \ No newline at end of file + input: "src/index.ts", + output: [ + { + dir: "dist", + format: "umd", + name: "lightningflowscanner", + sourcemap: true, + globals: { + "path-browserify": "p", + xmlbuilder2: "xmlbuilder2", + }, + } + ], + plugins: [ + nodePolyfills(), + typescript({tsconfig: `tsconfig.umd.json`}), + nodeResolve({ preferBuiltins: true }), + nodePolyfills(), + ], + external: ["path-browserify", "xmlbuilder2"], +}; diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..27af30e --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "resolveJsonModule": true, + "outDir": "out", + "lib": [ + "es2020.string", + "es6" + ], + "experimentalDecorators": true, + "sourceMap": true, + "rootDir": "src", + "strict": false, /* enable all strict type-checking options */ + "baseUrl": ".", + "declaration": true, + "esModuleInterop": true + }, + "exclude": [ + "node_modules", + "out/**", + ".idea/**", + "src/data/CustomRuleExample.ts", + "tests/**/*.test.ts" + ] + } + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.umd.json similarity index 95% rename from tsconfig.json rename to tsconfig.umd.json index 8455a88..349d551 100644 --- a/tsconfig.json +++ b/tsconfig.umd.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "ESNext", "target": "es6", - "outDir": "out", + "outDir": "dist", "moduleResolution":"node", "lib": [ "es2020.string",