Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/pg-esm-test/pg-protocol.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import protocol, { NoticeMessage, DatabaseError } from 'pg-protocol/dist/messages.js'
import { describe, it } from 'node:test'
import { strict as assert } from 'assert'
import { execFileSync } from 'node:child_process'

describe('pg-protocol', () => {
it('should export database error', () => {
Expand All @@ -15,4 +16,15 @@ describe('pg-protocol', () => {
it('should export NoticeMessage from file in dist folder', () => {
assert.ok(NoticeMessage)
})
it('should load the ESM entry without module syntax detection', () => {
const flags = process.allowedNodeEnvironmentFlags.has('--experimental-detect-module')
? ['--no-experimental-detect-module']
: []
const script =
"import { parse, serialize, DatabaseError } from 'pg-protocol'; if (!parse || !serialize || !DatabaseError) process.exit(1)"
execFileSync(process.execPath, [...flags, '--input-type=module', '-e', script], {
cwd: new URL('.', import.meta.url),
stdio: 'pipe',
})
})
})
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/pg-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./esm/index.js",
"import": "./esm/index.mjs",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
Expand Down
Loading