-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Use conditional exports for node.js #131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,19 @@ | |
"types": "dist/index.d.ts", | ||
"main": "dist/haws.umd.js", | ||
"module": "dist/index.js", | ||
"exports": { | ||
"node": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/haws.cjs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any compatible format would work. The file extension is the thing that needs to be different so node stops treating it as an ES module. @balloob said you had a possible solution to use two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I don't think the extension is needed anymore with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The directory structure with a second There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the error about it being an ES Module is thrown if you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The previous error reported here can be replicated by using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That makes no sense, |
||
} | ||
}, | ||
"repository": { | ||
"url": "https://github.com/home-assistant/home-assistant-js-websocket.git", | ||
"type": "git" | ||
}, | ||
"scripts": { | ||
"watch": "tsc --watch", | ||
"build": "tsc && rollup dist/index.js --format umd --name HAWS --file dist/haws.umd.js", | ||
"build": "tsc && rollup -c", | ||
"test": "tsc && mocha", | ||
"prepublishOnly": "rm -rf dist && yarn build && npm test" | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default { | ||
input: "dist/index.js", | ||
output: [ | ||
{ | ||
file: "dist/haws.cjs", | ||
format: "cjs", | ||
}, | ||
{ | ||
file: "dist/haws.umd.js", | ||
format: "umd", | ||
name: "HAWS", | ||
}, | ||
], | ||
}; |
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.
Do we have to make this exclusive to node?
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 tried to take the lightest touch solution, i.e., only modify for node.