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 ESM dist for npm package #102

Merged
merged 7 commits into from
Feb 12, 2024
Merged

build ESM dist for npm package #102

merged 7 commits into from
Feb 12, 2024

Conversation

turadg
Copy link
Member

@turadg turadg commented Feb 12, 2024

A recent conversion of a lib file to .ts broke downstream deep imports of it.

This builds .js files in the distribution and prevents deep imports.

packages/synthetic-chain/package.json Outdated Show resolved Hide resolved
packages/synthetic-chain/package.json Show resolved Hide resolved
"type": "module",
"module": "./dist/lib/index.js",
Copy link
Member

Choose a reason for hiding this comment

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

Let's add an exports field to prevent external users doing deep imports into dist

Copy link
Member Author

@turadg turadg Feb 12, 2024

Choose a reason for hiding this comment

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

I was reluctant to make that big a change yet, but I suppose consumers that it would break just won't upgrade.

However, it's for an additional improvement over the status quo. While it's good, it's not necessary to unblock the issue you raised. Can you wait for this to be future work?

Copy link
Member

Choose a reason for hiding this comment

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

it'll break consumers already with the move, might as well make it official. Introducing exports is technically semver major, might as well bite the bullet once

Copy link
Member Author

Choose a reason for hiding this comment

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

It's in ba21b9f

414dcf6 had broke CI because I made the proposals stop using deep imports too, but they're using older release so I backed that out and force-pushed. It doesn't affect what's in 0.0.6-3.

@turadg turadg marked this pull request as ready for review February 12, 2024 18:48
Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

Given the move / introduction of a dist folder, I would strongly prefer if the package.json added an exports field.

Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

Let's sync on supporting tests like Agoric/agoric-sdk#8786 and Agoric/agoric-sdk#8787

packages/synthetic-chain/src/lib/index.ts Outdated Show resolved Hide resolved
@turadg turadg force-pushed the ta/compile-ts branch 2 times, most recently from 8a506a4 to d11fa6a Compare February 12, 2024 19:39
entry: ['src/cli/cli.ts', 'src/lib/index.ts'],
format: ['esm'],
dts: true, // Generate declaration file (.d.ts)
sourcemap: true,
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 generate d.ts.map as well? Going to implementation is broken in VS Code without it.

Copy link
Member

Choose a reason for hiding this comment

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

Ugh apparently it's a limitation: egoist/tsup#564

Copy link
Member

Choose a reason for hiding this comment

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

Actually, it shouldn't be necessary here, I'm confused why go to definition is not working for me

@turadg turadg requested a review from mhofman February 12, 2024 21:35
Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

I have confirmed this works in an agoric-sdk branch!

@turadg turadg merged commit 4d5d6fb into main Feb 12, 2024
2 checks passed
@turadg turadg deleted the ta/compile-ts branch February 12, 2024 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants