Skip to content

Commit 2880187

Browse files
authored
feat: set build target to module (#98)
* feat: support dual package exports * chore!: set packages esm only
1 parent a460070 commit 2880187

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"keywords": [
1717
"swc-plugin"
1818
],
19-
"main": "next_superjson.wasm",
19+
"type": "module",
20+
"main": "./dist/next_superjson.wasm",
2021
"exports": {
2122
".": "./dist/next_superjson.wasm",
2223
"./tools": "./dist/tools.js",

tools/client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { SuperJSONProps, withSuperJSONPage } from "./tools";
44
import * as React from "react";
55

6-
export default function SuperJSONComponent<P>({
6+
export default function SuperJSONComponent<P extends JSX.IntrinsicAttributes>({
77
component,
88
props,
99
children

tools/tools.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// original tool source from 'babel-plugin-superjson-next'
22

3-
import * as hoistNonReactStatics from "hoist-non-react-statics";
3+
import hoistNonReactStatics from "hoist-non-react-statics";
44
import type { GetServerSideProps } from "next";
5-
import * as React from "react";
5+
import React from "react";
66
import SuperJSON from "superjson";
77

88
export type SuperJSONProps<P> = P & {
99
_superjson?: ReturnType<typeof SuperJSON.serialize>["meta"];
1010
};
1111

12-
export function withSuperJSONProps<P>(
12+
export function withSuperJSONProps<P extends JSX.IntrinsicAttributes>(
1313
gssp: GetServerSideProps<P>,
1414
exclude: string[] = []
1515
): GetServerSideProps<SuperJSONProps<P>> {
@@ -87,7 +87,7 @@ export function deserializeProps<P>(serializedProps: SuperJSONProps<P>): P {
8787
return SuperJSON.deserialize({ json: props as any, meta: _superjson });
8888
}
8989

90-
export function withSuperJSONPage<P>(
90+
export function withSuperJSONPage<P extends JSX.IntrinsicAttributes>(
9191
Page: React.ComponentType<P>
9292
): React.ComponentType<SuperJSONProps<P>> {
9393
function WithSuperJSON(serializedProps: SuperJSONProps<P>) {

tsconfig.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
"compilerOptions": {
44
"declaration": true,
55
"sourceMap": true,
6-
"target": "ES5",
6+
"target": "ESNext",
77
"rootDir": "tools",
88
"outDir": "dist",
99
"strict": true,
10-
"moduleResolution": "node",
11-
"jsx": "react",
10+
"module": "ESNext",
11+
"moduleResolution": "Bundler",
12+
"esModuleInterop": true,
13+
"jsx": "react-jsx",
1214
"skipLibCheck": true
1315
}
1416
}

0 commit comments

Comments
 (0)