Skip to content

Commit 2162e26

Browse files
committed
Migrate to pure esm type module
1 parent e7d190b commit 2162e26

5 files changed

+20
-18
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"form",
1313
"hook"
1414
],
15-
"main": "lib/index.js",
16-
"module": "lib/index.esm.js",
17-
"types": "lib/types/index.d.ts",
15+
"type": "module",
16+
"exports": "./lib/index.js",
17+
"types": "./lib/index.d.ts",
1818
"files": [
1919
"lib"
2020
],

src/HubspotProvider.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import React, {
77
useState,
88
useDebugValue,
99
} from "react";
10-
import Script from "next/script";
11-
import type { ScriptProps } from "next/script";
10+
import NextScript from "next/script.js";
11+
import type { ScriptProps } from "next/script.js";
12+
13+
// https://github.com/vercel/next.js/issues/46078
14+
const Script = NextScript as unknown as React.FC<ScriptProps>;
1215

1316
interface HubspotContextProps {
1417
/** Is Hubspot script loaded */

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from "./hubspot.types";
1+
export * from "./hubspot.types.js";
22

3-
export * from "./HubspotProvider";
4-
export * from "./useHubspotForm";
3+
export * from "./HubspotProvider.js";
4+
export * from "./useHubspotForm.js";

src/useHubspotForm.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useState, useDebugValue } from "react";
2-
import { useHubspotContext } from "./HubspotProvider";
3-
import type { HubspotFormProps } from "./hubspot.types";
2+
import { useHubspotContext } from "./HubspotProvider.js";
3+
import type { HubspotFormProps } from "./hubspot.types.js";
44

55
interface UseHubSpotFormProps extends HubspotFormProps {}
66

tsconfig.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
"compilerOptions": {
33
"rootDir": "src",
44
"declaration": true,
5-
"declarationDir": "types",
6-
"module": "esnext",
7-
"target": "es6",
8-
"lib": ["es6", "dom", "es2016", "es2017"],
9-
"sourceMap": true,
10-
"inlineSources": true,
5+
"declarationDir": "lib",
6+
"module": "node16",
7+
"target": "es2020",
8+
"sourceMap": false,
119
"jsx": "react",
12-
"moduleResolution": "node",
13-
"esModuleInterop": true
10+
"moduleResolution": "node16",
11+
"esModuleInterop": true,
12+
"emitDeclarationOnly": true
1413
},
1514
"include": ["src"],
1615
"exclude": ["node_modules", "lib"]

0 commit comments

Comments
 (0)