Skip to content

Commit

Permalink
Merge pull request #11 from prisma/fix/valid-exports-map
Browse files Browse the repository at this point in the history
fix: Ensure that entries in export map point to existing files
  • Loading branch information
SevInf authored Sep 6, 2023
2 parents 48801d0 + b6f1e0e commit 5d34a75
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "types/index.d.ts",
"types": "dist/index.d.ts",
"homepage": "https://github.com/prisma/extension-read-replicas",
"repository": {
"type": "git",
Expand All @@ -18,11 +18,11 @@
".": {
"require": {
"default": "./dist/index.js",
"types": "./types/index.d.ts"
"types": "./dist/index.d.ts"
},
"import": {
"default": "./dist/index.mjs",
"types": "./types/index.d.mts"
"types": "./dist/index.d.mts"
}
}
},
Expand Down
20 changes: 20 additions & 0 deletions tests/package.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import execa from 'execa'
import path from 'path'
import fs from 'fs/promises'
import pkg from '../package.json'

function runFile(file: string) {
return execa('node', [path.join(__dirname, file)])
Expand All @@ -12,3 +14,21 @@ test('common js module can be loaded', async () => {
test('ES module can be loaded', async () => {
await runFile('esm.mjs')
})

async function assertFileExists(filePath: string) {
const stat = await fs.stat(filePath)
expect(stat.isFile()).toBe(true)
}

test('entires in package json point to existing files', async () => {
await assertFileExists(pkg.main)
await assertFileExists(pkg.module)
await assertFileExists(pkg.types)
for (const exportDefinition of Object.values(pkg.exports)) {
for (const entry of Object.values(exportDefinition)) {
for (const filePath of Object.values(entry)) {
await assertFileExists(filePath)
}
}
}
})

0 comments on commit 5d34a75

Please sign in to comment.