From 31010520662b40637e7fc6fca1d36f305348922a Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Sat, 29 Oct 2022 09:44:26 +1000 Subject: [PATCH] Fix ESM output for native Node.js usage --- Makefile | 2 ++ package.json | 8 ++++---- src/index.ts | 2 +- test/unit/escape.spec.ts | 4 ++-- test/unit/index.spec.ts | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 3521cb1..205a465 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +export NODE_OPTIONS := --experimental-vm-modules --redirect-warnings=artifacts/node-warnings + JS_SIZE_LIMIT_REQ += artifacts/dist ################################################################################ diff --git a/package.json b/package.json index e1eaa40..c503339 100644 --- a/package.json +++ b/package.json @@ -36,15 +36,15 @@ "node": ">=14" }, "scripts": { - "prepublishOnly": "tsc -p tsconfig.build.json", - "size-limit-build": "tsc -p tsconfig.build.json", + "prepublishOnly": "make artifacts/dist", + "size-limit-build": "make artifacts/dist", "size-limit-clean": "rm -rf artifacts/dist" }, "devDependencies": { "@size-limit/preset-small-lib": "^8.0.0", "@snout/eslint-config": "^3.2.2", - "@snout/jest-config": "^2.2.0", - "@snout/tsconfig": "^2.0.0", + "@snout/jest-config": "^3.0.0", + "@snout/tsconfig": "^3.0.0", "prettier": "^2.7.1", "prettier-plugin-organize-imports": "^3.0.1", "size-limit": "^8.0.0", diff --git a/src/index.ts b/src/index.ts index 7fb0316..fcb0b81 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1 @@ -export { escape } from "./main"; +export { escape } from "./main.js"; diff --git a/test/unit/escape.spec.ts b/test/unit/escape.spec.ts index 78383a0..7443dbd 100644 --- a/test/unit/escape.spec.ts +++ b/test/unit/escape.spec.ts @@ -1,5 +1,5 @@ -import { escape } from "../../src/main"; -import { hasType } from "../helpers"; +import { escape } from "../../src/main.js"; +import { hasType } from "../helpers.js"; describe("escape()", () => { it("should escape strings for use within regular expressions", () => { diff --git a/test/unit/index.spec.ts b/test/unit/index.spec.ts index 3bde349..5637b1d 100644 --- a/test/unit/index.spec.ts +++ b/test/unit/index.spec.ts @@ -1,5 +1,5 @@ -import * as index from "../../src/index"; -import { escape } from "../../src/main"; +import * as index from "../../src/index.js"; +import { escape } from "../../src/main.js"; describe("module index", () => { it("should provide access to escape()", () => {