fix: fix coverage report by disabling sourcemap in build used in UTs
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 25 Sep 2023 19:52:26 +0000 (21:52 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 25 Sep 2023 19:52:26 +0000 (21:52 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
@types/events.d.ts
package.json
rollup.config.mjs

index ae0f8f50b59ec40297da691c52860f11defacbef..1432a57e0eb6e256ea03fb1f40365bfb8b8067e5 100644 (file)
@@ -14,7 +14,7 @@ declare module 'events' {
     EventEmitterOptions {
     /**
      * The type of async event.
-     * @default new.target.name
+     * @default new.target.name if instantiated from a child class.
      */
     name?: string
   }
@@ -30,7 +30,7 @@ declare module 'events' {
    * @since v17.4.0, v16.14.0
    */
   export class EventEmitterAsyncResource extends EventEmitter {
-    constructor (options?: EventEmitterAsyncResourceOptions)
+    constructor (options: EventEmitterAsyncResourceOptions)
     /**
      * Call all `destroy` hooks. This should only ever be called once. An error will
      * be thrown if it is called more than once. This **must** be manually called. If
index 1a8d9617c3df05af9a80af81f2dd9795ee7c1245..396c9e5b03e3f9948620b7c8fbf941fa86d9be89 100644 (file)
@@ -22,7 +22,7 @@
     "benchmark": "pnpm build && node -r source-map-support/register benchmarks/internal/bench.mjs",
     "benchmark:debug": "pnpm build && node -r source-map-support/register --inspect benchmarks/internal/bench.mjs",
     "benchmark:prod": "pnpm build:prod && node benchmarks/internal/bench.mjs",
-    "test": "pnpm build && c8 mocha 'tests/**/*.test.js'",
+    "test": "pnpm build --environment SOURCEMAP:false && c8 mocha 'tests/**/*.test.js'",
     "test:debug": "pnpm build && mocha --no-parallel --inspect 'tests/**/*.test.js'",
     "coverage": "c8 report --reporter=lcov",
     "coverage:html": "c8 report --reporter=html",
index 8f1f26562a4817d75a018129b3a09f76fd9129ab..3d069f7f7b0f6956ec192bb40748db09bee76a1c 100644 (file)
@@ -24,6 +24,7 @@ const availableParallelism = () => {
 const isDevelopmentBuild = env.BUILD === 'development'
 const isAnalyzeBuild = env.ANALYZE
 const isDocumentationBuild = env.DOCUMENTATION
+const sourcemap = env.SOURCEMAP !== 'false'
 
 const maxWorkers = Math.floor(availableParallelism() / 2)
 
@@ -36,21 +37,21 @@ export default defineConfig([
         format: 'cjs',
         ...(isDevelopmentBuild && {
           dir: './lib',
-          sourcemap: true,
           preserveModules: true,
           preserveModulesRoot: './src'
         }),
         ...(!isDevelopmentBuild && {
           file: './lib/index.js',
-          sourcemap: true,
           plugins: [terser({ maxWorkers })]
+        }),
+        ...(sourcemap && {
+          sourcemap
         })
       },
       {
         format: 'esm',
         ...(isDevelopmentBuild && {
           dir: './lib',
-          sourcemap: true,
           entryFileNames: '[name].mjs',
           chunkFileNames: '[name]-[hash].mjs',
           preserveModules: true,
@@ -58,8 +59,10 @@ export default defineConfig([
         }),
         ...(!isDevelopmentBuild && {
           file: './lib/index.mjs',
-          sourcemap: true,
           plugins: [terser({ maxWorkers })]
+        }),
+        ...(sourcemap && {
+          sourcemap
         })
       }
     ],