Skip to content

Commit

Permalink
Fix ESM output for native Node.js usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Oct 29, 2022
1 parent 0d395fc commit d2e236b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export NODE_OPTIONS := --experimental-vm-modules --redirect-warnings=artifacts/node-warnings

JS_SIZE_LIMIT_REQ += artifacts/dist

################################################################################
Expand Down
8 changes: 7 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import config from "@snout/jest-config";
export default {
...config,
transform: {
"\\.tsx?$": ["ts-jest", { tsconfig: "test/tsconfig.json" }],
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
tsconfig: "test/tsconfig.json",
},
],
},
};
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"main": "artifacts/dist/index.js",
"types": "artifacts/dist/index.d.ts",
"exports": {
".": "./artifacts/dist/index.js"
".": {
"types": "./artifacts/dist/index.d.ts",
"import": "./artifacts/dist/index.js",
"default": "./artifacts/dist/index.js"
}
},
"sideEffects": false,
"files": [
Expand All @@ -35,20 +39,20 @@
"size-limit-clean": "rm -rf artifacts/dist"
},
"dependencies": {
"@snout/regexp": "^0.3.0"
"@snout/regexp": "^0.3.2"
},
"peerDependencies": {
"@snout/router-path": "^0.6.0"
},
"devDependencies": {
"@size-limit/preset-small-lib": "^8.0.0",
"@snout/eslint-config": "^3.2.2",
"@snout/jest-config": "^2.1.0",
"@snout/jest-config": "^3.0.0",
"@snout/router-path": "^0.7.2",
"@snout/tsconfig": "^2.0.0",
"@snout/tsconfig": "^3.0.0",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.0.0",
"size-limit": "^8.0.0",
"typescript": "^4.4.3"
"typescript": "^4.8.4"
}
}
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { int } from "./coercion";
export { optional } from "./optional";
export { any, some } from "./repeating";
export { createSlash, slash } from "./slash";
export { int } from "./coercion.js";
export { optional } from "./optional.js";
export { any, some } from "./repeating.js";
export { createSlash, slash } from "./slash.js";
2 changes: 1 addition & 1 deletion test/unit/any.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { path } from "@snout/router-path";
import { any } from "../../src/repeating";
import { any } from "../../src/repeating.js";

describe("any()", () => {
it("should allow building from an array", () => {
Expand Down
10 changes: 5 additions & 5 deletions test/unit/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { int } from "../../src/coercion";
import * as index from "../../src/index";
import { optional } from "../../src/optional";
import { any, some } from "../../src/repeating";
import { createSlash, slash } from "../../src/slash";
import { int } from "../../src/coercion.js";
import * as index from "../../src/index.js";
import { optional } from "../../src/optional.js";
import { any, some } from "../../src/repeating.js";
import { createSlash, slash } from "../../src/slash.js";

describe("module index", () => {
it("should provide access to int()", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/int.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { path } from "@snout/router-path";
import { int } from "../../src/coercion";
import { int } from "../../src/coercion.js";

describe("int()", () => {
it("should allow building from a number", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/optional.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { normalizeParam, path } from "@snout/router-path";
import { int } from "../../src/coercion";
import { optional } from "../../src/optional";
import { int } from "../../src/coercion.js";
import { optional } from "../../src/optional.js";

describe("optional()", () => {
it("should allow building with or without a defined arg", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/slash.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { path } from "@snout/router-path";
import { createSlash, slash } from "../../src/slash";
import { createSlash, slash } from "../../src/slash.js";

describe("createSlash()", () => {
it("should allow building with a boolean indicating whether to include the slash", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/some.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { path } from "@snout/router-path";
import { some } from "../../src/repeating";
import { some } from "../../src/repeating.js";

describe("some()", () => {
it("should allow building from an array", () => {
Expand Down

0 comments on commit d2e236b

Please sign in to comment.