Skip to content
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

build(client-utils): use export map instead of 'browser' field #20665

Merged
merged 8 commits into from
Apr 15, 2024

Conversation

DLehenbauer
Copy link
Contributor

@DLehenbauer DLehenbauer commented Apr 15, 2024

Previously, we used the 'browser' field to implement different entry points for browser vs. node.

This field does not appear to be supported by CloudPack. Instead, we now use conditional exports in the export map.

@github-actions github-actions bot added the base: main PRs targeted against main branch label Apr 15, 2024
@DLehenbauer DLehenbauer reopened this Apr 15, 2024
"require": {
"types": "./dist/bufferBrowser.d.ts",
"default": "./dist/bufferBrowser.js"
}
}
}
},
"main": "lib/indexNode.js",
"browser": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CloudPack doesn't use it. If it passes our Jest tests, I think we're good to go.

@DLehenbauer DLehenbauer changed the title wip: browser fix build(client-utils): use export map instead of 'browser' field Apr 15, 2024
@github-actions github-actions bot added the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Apr 15, 2024
@DLehenbauer DLehenbauer marked this pull request as ready for review April 15, 2024 21:51
@@ -3,7 +3,8 @@
* Licensed under the MIT License.
*/

import { IsoBuffer } from "./indexNode.js";
// Note: The exports map in package.json will correct this import to "./bufferNode.js" in node environments
import { IsoBuffer } from "./bufferBrowser.js";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: changed to 'bufferBrowser.js' instead of 'indexBrowser.js' to avoid import cycle.

@DLehenbauer DLehenbauer enabled auto-merge (squash) April 15, 2024 22:15
@DLehenbauer DLehenbauer disabled auto-merge April 15, 2024 23:04
@DLehenbauer DLehenbauer merged commit 44da14a into main Apr 15, 2024
30 checks passed
@DLehenbauer DLehenbauer deleted the browser-fix branch April 15, 2024 23:04
Comment on lines -28 to -33
"browser": {
"./dist/indexNode.js": "./dist/indexBrowser.js",
"./dist/indexNode.d.ts": "./dist/indexBrowser.d.ts",
"./lib/indexNode.js": "./lib/indexBrowser.js",
"./lib/indexNode.d.ts": "./lib/indexBrowser.d.ts"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these means any uses of indexNode.js will not be redirected to indexBrowser.js. trace.ts uses indexNode.js; so, that needs corrected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related issue: #21252

Comment on lines -28 to -33
"browser": {
"./dist/indexNode.js": "./dist/indexBrowser.js",
"./dist/indexNode.d.ts": "./dist/indexBrowser.d.ts",
"./lib/indexNode.js": "./lib/indexBrowser.js",
"./lib/indexNode.d.ts": "./lib/indexBrowser.d.ts"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also replicated in src/cjs/package.json that is needed for webpack (with CJS). AB#7374 would help avoid getting out of sync.

scottn12 pushed a commit to scottn12/FluidFramework that referenced this pull request Jun 5, 2024
…soft#20665)

Previously, we used [the 'browser'
field](https://github.com/defunctzombie/package-browser-field-spec) to
implement different entry points for browser vs. node.

This field does not appear to be supported by CloudPack. Instead, we now
use [conditional
exports](https://nodejs.org/docs/latest-v18.x/api/packages.html#conditional-exports)
in the export map.
scottn12 pushed a commit to scottn12/FluidFramework that referenced this pull request Jun 5, 2024
…soft#20665)

Previously, we used [the 'browser'
field](https://github.com/defunctzombie/package-browser-field-spec) to
implement different entry points for browser vs. node.

This field does not appear to be supported by CloudPack. Instead, we now
use [conditional
exports](https://nodejs.org/docs/latest-v18.x/api/packages.html#conditional-exports)
in the export map.
scottn12 pushed a commit to scottn12/FluidFramework that referenced this pull request Jun 5, 2024
…soft#20665)

Previously, we used [the 'browser'
field](https://github.com/defunctzombie/package-browser-field-spec) to
implement different entry points for browser vs. node.

This field does not appear to be supported by CloudPack. Instead, we now
use [conditional
exports](https://nodejs.org/docs/latest-v18.x/api/packages.html#conditional-exports)
in the export map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants