Skip to content

Commit

Permalink
feat: provide ES Module build
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Aug 31, 2024
1 parent 460b3a5 commit ff9076b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./rsc": {
"import": "./dist/rsc.js",
"import": "./dist/rsc.mjs",
"require": "./dist/rsc.js",
"types": "./dist/rsc.d.ts"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/field-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"private": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"license": "MIT",
"scripts": {
"lint": "eslint \"**/*.ts*\"",
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-emotion-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"private": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"license": "MIT",
"scripts": {
"lint": "eslint \"**/*.ts*\"",
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-heading-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"private": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./dist/index.css": "./dist/index.css"
},
"license": "MIT",
"scripts": {
"lint": "eslint \"**/*.ts*\"",
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-heading-analyzer/src/HeadingAnalyzer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import { getClassNameFactory } from "@/core/lib";
const getClassName = getClassNameFactory("HeadingAnalyzer", styles);
const getClassNameItem = getClassNameFactory("HeadingAnalyzerItem", styles);

import ReactFromJSON from "react-from-json";
import ReactFromJSONModule from "react-from-json";

// Synthetic import
const ReactFromJSON =
(ReactFromJSONModule as unknown as { default: typeof ReactFromJSONModule })
.default || ReactFromJSONModule;

const dataAttr = "data-puck-heading-analyzer-id";

Expand Down
6 changes: 4 additions & 2 deletions packages/tsup-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import fs from "fs";
import path from "path";
import postcss from "postcss";
import postcssModules from "postcss-modules";
import type { Options } from "tsup";

const config = {
const config: Options = {
dts: true,
format: "cjs",
format: ["cjs", "esm"],
inject: ["../tsup-config/react-import.js"],
external: ["react", "react-dom", "@measured/puck"],
esbuildPlugins: [
{
name: "css-module",
Expand Down

0 comments on commit ff9076b

Please sign in to comment.