Skip to content

Commit

Permalink
fix: use dynamic import for p-map esm module
Browse files Browse the repository at this point in the history
  • Loading branch information
cschanaj committed Dec 3, 2023
1 parent 479db72 commit 0dbb810
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const path = require('path')
const { rimraf } = require('rimraf')
const SourceMaps = require('./lib/source-maps')
const TestExclude = require('test-exclude')
const pMap = require('p-map')
const getPackageType = require('get-package-type')

const debugLog = debuglog('nyc')
Expand Down Expand Up @@ -233,6 +232,7 @@ class NYC {
this._loadAdditionalModules()

const stats = await fs.lstat(input)
const { default: pMap } = await import('p-map')
if (stats.isDirectory()) {
inputDir = input

Expand Down Expand Up @@ -421,6 +421,7 @@ class NYC {
async getCoverageMapFromAllCoverageFiles (baseDirectory) {
const map = libCoverage.createCoverageMap({})
const files = await this.coverageFiles(baseDirectory)
const { default: pMap } = await import('p-map')

await pMap(
files,
Expand Down Expand Up @@ -523,6 +524,7 @@ class NYC {
// TODO: Remove from nyc v16
async coverageData (baseDirectory) {
const files = await this.coverageFiles(baseDirectory)
const { default: pMap } = await import('p-map')
return pMap(
files,
f => this.coverageFileLoad(f, baseDirectory),
Expand Down
2 changes: 1 addition & 1 deletion lib/source-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const libSourceMaps = require('istanbul-lib-source-maps')
const fs = require('./fs-promises')
const os = require('os')
const path = require('path')
const pMap = require('p-map')

class SourceMaps {
constructor (opts) {
Expand Down Expand Up @@ -57,6 +56,7 @@ class SourceMaps {
}

async reloadCachedSourceMaps (report) {
const { default: pMap } = await import('p-map')
await pMap(
Object.entries(report),
async ([absFile, fileReport]) => {
Expand Down

0 comments on commit 0dbb810

Please sign in to comment.