-
Notifications
You must be signed in to change notification settings - Fork 14
feat: make it dual package friendly #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -2,15 +2,18 @@ module github.com/reteps/dockerfmt | |||
|
|||
go 1.24.1 | |||
|
|||
require ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run go mod tidy
.
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"module-sync": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For require(ESM)
.
Could give it a try. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try a dynamic import before doing this.
@@ -10,7 +10,9 @@ import { | |||
const getWasm = () => { | |||
return fs.readFile( | |||
path.resolve( | |||
path.dirname(fileURLToPath(import.meta.url)), | |||
typeof __dirname === 'undefined' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cjs friendly.
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"devDependencies": { | ||
"@pkgr/rollup": "^6.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need rollup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR bundle cjs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Maybe a separate build would work:
https://tduyng.com/blog/dual-package-typescript/
npx tsc -p tsconfig.lib.json --module NodeNext --outDir lib/esm
echo '{"type": "module"}' > lib/esm/package.json
npx tsc -p tsconfig.lib.json --module CommonJS --moduleResolution Node --outDir lib/cjs
echo '{"type": "commonjs"}' > lib/cjs/package.json
echo 'Compilation successful'
I'll see if I can play around with this later.
No need, this package can be ESM only. |
close un-ts/prettier#434
cc @reteps