diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4b790ef..6d3aaf46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,6 @@ jobs: - '18' - '20' - '22' - steps: - uses: actions/checkout@v4 - name: Setup Node.js ${{ matrix.node-version }} @@ -24,11 +23,9 @@ jobs: with: cache: npm node-version: ${{ matrix.node-version }} - - run: npm install -g nyc - run: npm ci - run: npm run test:cover - - uses: codecov/codecov-action@v5 with: files: coverage/coverage-final.json @@ -39,7 +36,6 @@ jobs: strategy: matrix: browser: [ChromeHeadless, FirefoxHeadless] - steps: - uses: actions/checkout@v4 - name: Setup Node.js @@ -54,7 +50,6 @@ jobs: deno: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Setup Deno @@ -62,15 +57,14 @@ jobs: with: deno-version: "v2.x" - run: npm ci - - run: deno test test/deno_test.ts + - run: npm run test:deno bun: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v2 - run: bun install - - run: bun test test/bun.spec.ts + - run: npm run test:bun diff --git a/karma.conf.ts b/karma.conf.ts index 8ee789f1..b4a51507 100644 --- a/karma.conf.ts +++ b/karma.conf.ts @@ -43,9 +43,8 @@ export default function configure(config: any) { test: /\.tsx?$/, loader: "ts-loader", options: { - configFile: "tsconfig.test-karma.json", - // FIXME: some types for dependencies cannot be resolved, so ignore type checking for now. transpileOnly: true, + configFile: "tsconfig.test-karma.json", }, }, ], diff --git a/package.json b/package.json index a2603f16..5d03ab56 100644 --- a/package.json +++ b/package.json @@ -4,21 +4,22 @@ "description": "MessagePack for ECMA-262/JavaScript/TypeScript", "author": "The MessagePack community", "license": "ISC", - "main": "./dist/index.js", + "main": "./dist.cjs/index.js", "module": "./dist.esm/index.mjs", "cdn": "./dist.umd/msgpack.min.js", "unpkg": "./dist.umd/msgpack.min.js", - "types": "./dist/index.d.ts", + "types": "./dist.esm/index.d.ts", "sideEffects": false, "scripts": { "build": "npm publish --dry-run", - "prepare": "npm run clean && webpack --bail && tsc --build tsconfig.dist.json tsconfig.dist.esm.json && ts-node tools/esmify.ts dist.esm/*.js dist.esm/*/*.js", + "prepare": "npm run clean && webpack --bail && tsc --build tsconfig.dist.cjs.json tsconfig.dist.esm.json && ts-node tools/esmify.ts dist.esm/*.js dist.esm/*/*.js", "prepublishOnly": "npm run test:dist", "clean": "rimraf build dist dist.*", "test": "mocha 'test/**/*.test.ts'", "test:dist": "npm run lint && npm run test && npm run test:deno", "test:cover": "npm run cover:clean && npx nyc --no-clean npm run 'test' && npm run cover:report", "test:deno": "deno test test/deno_test.ts", + "test:bun": "bun test test/bun.spec.ts", "test:fuzz": "npm exec --yes -- jsfuzz@git+https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/jsfuzz.git#39e6cf16613a0e30c7a7953f62e64292dbd5d3f3 --fuzzTime 60 --no-versifier test/decode.jsfuzz.js corpus", "cover:clean": "rimraf .nyc_output coverage/", "cover:report": "npx nyc report --reporter=text-summary --reporter=html --reporter=json", diff --git a/tsconfig.dist.json b/tsconfig.dist.cjs.json similarity index 58% rename from tsconfig.dist.json rename to tsconfig.dist.cjs.json index d78a9246..bb97412b 100644 --- a/tsconfig.dist.json +++ b/tsconfig.dist.cjs.json @@ -1,9 +1,11 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "./dist", - "declaration": true, + "module": "CommonJS", + "outDir": "./dist.cjs", + "declaration": false, "noEmitOnError": true, + "noEmit": false, "incremental": false }, "include": ["src/**/*.ts"] diff --git a/tsconfig.dist.esm.json b/tsconfig.dist.esm.json index 5ee9ac5e..42aeff69 100644 --- a/tsconfig.dist.esm.json +++ b/tsconfig.dist.esm.json @@ -1,10 +1,11 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "es2020", + "module": "ES2020", "outDir": "./dist.esm", - "declaration": false, + "declaration": true, "noEmitOnError": true, + "noEmit": false, "incremental": false }, "include": ["src/**/*.ts"] diff --git a/tsconfig.dist.webpack.json b/tsconfig.dist.webpack.json index edbaa9bd..687889a7 100644 --- a/tsconfig.dist.webpack.json +++ b/tsconfig.dist.webpack.json @@ -1,8 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "esnext", + "module": "ESNext", "noEmitOnError": true, + "noEmit": false, "outDir": "./build/webpack" }, "include": ["src/**/*.ts"] diff --git a/tsconfig.json b/tsconfig.json index b97d9fec..60e468c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ /* Basic Options */ "target": "ES2020", /* the baseline */ "module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - "lib": ["ES2024", "dom"], /* Specify library files to be included in the compilation. */ + "lib": ["ES2024", "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', or 'react'. */ @@ -41,6 +41,8 @@ "noPropertyAccessFromIndexSignature": true, "noImplicitOverride": true, "verbatimModuleSyntax": false, + // "allowImportingTsExtensions": true, + "noEmit": true, /* Module Resolution Options */ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ @@ -55,6 +57,7 @@ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ "resolveJsonModule": true, + "skipLibCheck": true, "forceConsistentCasingInFileNames": true // "erasableSyntaxOnly": true @@ -69,5 +72,5 @@ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ }, - "exclude": ["assembly"] + "exclude": ["example", "benchmark", "test/bun*", "test/deno*", "mod.ts"] } diff --git a/tsconfig.test-karma.json b/tsconfig.test-karma.json index 31174000..560ff840 100644 --- a/tsconfig.test-karma.json +++ b/tsconfig.test-karma.json @@ -1,8 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "esnext", + "module": "ESNext", "outDir": "./build/karma", + "noEmit": false, "incremental": false } } diff --git a/webpack.config.mjs b/webpack.config.mjs index 1eeb233f..3c15a82b 100644 --- a/webpack.config.mjs +++ b/webpack.config.mjs @@ -26,6 +26,7 @@ const config = { test: /\.tsx?$/, loader: "ts-loader", options: { + transpileOnly: true, configFile: "tsconfig.dist.webpack.json", }, },