Brian C 940479bc4b
Add esm exports (#3423)
* build: add esm exports

* fix: add defaults as per arethetypeswrong report

* fix: add missing types

* lint

* Fix broken tests

* Add (failing) test for esm compat

* Begin moving files to proper extension and adding tests

* Add tests for connection-string and fix cloudflare module type and esm compat

* Add query-stream and cursor as esm exports

* Update PR copilot review

* Publish

 - pg-cloudflare@1.1.2-alpha.0
 - pg-connection-string@2.7.1-alpha.0
 - pg-cursor@2.13.2-alpha.0
 - pg-esm-test@1.0.1-alpha.0
 - pg-native@3.3.1-alpha.0
 - pg-pool@3.8.1-alpha.0
 - pg-protocol@1.8.1-alpha.0
 - pg-query-stream@4.8.2-alpha.0
 - pg@8.14.2-alpha.0

* More cf compat work

* Publish

 - pg-cloudflare@1.1.2-alpha.1
 - pg-cursor@2.13.2-alpha.1
 - pg-esm-test@1.0.1-alpha.1
 - pg-pool@3.8.1-alpha.1
 - pg-query-stream@4.8.2-alpha.1
 - pg@8.14.2-alpha.1

* Add more cf compat and update tests

* Make tests pass - update exports for esm

* Use env vars for test connection in cf tests

* Fix lint

* Fit vitest into existing legacy framework

* Skip worker tests on node below 18

* Revert doc changes for now

* Remove legacy worker test in favor of vitest

---------

Co-authored-by: Luca Ban <mesqueeb@users.noreply.github.com>
2025-04-22 10:53:22 -05:00

65 lines
1.7 KiB
Makefile

SHELL := /bin/sh
connectionString=postgres://
params := $(connectionString)
node-command := xargs -n 1 -I file node file $(params)
.PHONY : test test-connection test-integration bench test-native \
publish update-npm
all:
npm install
help:
@echo "make test-all [connectionString=postgres://<your connection string>]"
test: test-unit
test-all: test-unit test-integration test-native test-worker
update-npm:
@npm i npm --global
bench:
@find benchmark -name "*-bench.js" | $(node-command)
test-unit:
@find test/unit -name "*-tests.js" | $(node-command)
test-connection:
@echo "***Testing connection***"
@node script/create-test-tables.js $(params)
test-native: test-connection
@echo "***Testing native bindings***"
ifeq ($(TEST_SKIP_NATIVE), true)
@echo "***Skipping tests***"
else
@find test/native -name "*-tests.js" | $(node-command)
@find test/integration -name "*-tests.js" | $(node-command) native
endif
test-integration: test-connection
@echo "***Testing Pure Javascript***"
@find test/integration -name "*-tests.js" | $(node-command)
test-binary: test-connection
@echo "***Testing Pure Javascript (binary)***"
@find test/integration -name "*-tests.js" | $(node-command) binary
test-pool:
@find test/integration/connection-pool -name "*.js" | $(node-command) binary
test-worker:
# this command only runs in node 18.x and above since there are
# worker specific items missing from the node environment in lower versions
@if [[ $(shell node --version | sed 's/v//' | cut -d'.' -f1) -ge 18 ]]; then \
echo "***Testing Cloudflare Worker support***"; \
yarn vitest run -c test/vitest.config.mts test/cloudflare/ --no-watch -- $(params); \
else \
echo "Skipping test-worker: Node.js version is less than 18."; \
fi