-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create esm dir package.json file to fix mui-tiptap nodejs import
Should resolve #256
- Loading branch information
1 parent
0ec02e7
commit ab5386f
Showing
3 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Create a `package.json` file in the `dist/esm` build output directory with | ||
// {"type: "module"}, which should ensure that mui-tiptap can be imported | ||
// properly as ESM in a node.js context (fixing | ||
// https://github.com/sjdemartini/mui-tiptap/issues/256). | ||
// See: | ||
// - https://github.com/microsoft/TypeScript/issues/18442#issuecomment-1377529164 | ||
// - https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html | ||
// - https://github.com/nodejs/node/issues/34515 | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const dir = path.join(__dirname, "dist", "esm"); | ||
const filePath = path.join(dir, "package.json"); | ||
const content = JSON.stringify({ type: "module" }, null, 2); | ||
|
||
fs.writeFileSync(filePath, content, "utf8"); | ||
|
||
// Print the path relative to __dirname: | ||
console.log(`Created ${path.relative(__dirname, filePath)}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters