Expand info on module condition and dual package hazard#40
Open
Andarist wants to merge 1 commit intoesbuild:mainfrom
Open
Expand info on module condition and dual package hazard#40Andarist wants to merge 1 commit intoesbuild:mainfrom
module condition and dual package hazard#40Andarist wants to merge 1 commit intoesbuild:mainfrom
Conversation
Andarist
commented
May 31, 2023
| @@ -3665,17 +3665,17 @@ body: | |||
|
|
|||
| - p: > | |||
| The following condition is also automatically included when the [platform](#platform) | |||
Author
There was a problem hiding this comment.
I think that especially the change to mention neutral platform here is especially important because otherwise this could be misread by other implementers.
Andarist
commented
May 31, 2023
| that can work with node because node deliberately doesn't implement loading | ||
| ESM using `require`. | ||
|
|
||
| - p: > |
Author
There was a problem hiding this comment.
We have also found out that to improve code portability between bundlers etc we are forced to structure things like this when the default export is involved:
// dist/pkg.mjs
export * from "./pkg.cjs.js";
export { _default as default } from "./pkg.cjs.default.js";
// dist/pkg.cjs.default.js
exports._default = require('./pkg.cjs.js').default
// dist/pkg.cjs.js
/*
transpiled CJS content of the package with all named exports and named default
don't try to avoid `.default` here
*/The same problem spills into TS declarations:
// dist/pkg.d.mts
export * from "./index.js"; // yes, we are in the declaration file but we are using .js extension here
export { _default as default } from "./pkg.cjs.default.js";
// dist/pkg.cjs.default.d.ts
export { default as _default } from "./index.js"
// dist/index.d.ts
/*
actual type declarations produced by TS
*/I'm not sure if you want to include any of this in your docs though. It gets a little bit crazy and I wish that we wouldn't have to do those steps but here we are.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.