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

Fix Token program ESM exports #3508

Merged
merged 23 commits into from
Aug 23, 2022
Merged

Fix Token program ESM exports #3508

merged 23 commits into from
Aug 23, 2022

Conversation

jordaaash
Copy link
Contributor

@jordaaash jordaaash commented Aug 22, 2022

This is the second of two PRs to address #3502, this one for the Token program JS (#3507 for Memo, which it builds on top of). This fixes the issues that build systems have with .mjs files by exporting .js files. It also restructures the project to be similar to Wallet Adapter / the TypeScript monorepo template I've been using.

Fixes #3502

@jordaaash jordaaash requested a review from joncinque August 22, 2022 20:32
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Just the one question, but otherwise looks good. Also, the node runner for the GitHub action needs to be updated to version 16

token/js/package.json Outdated Show resolved Hide resolved
token/js/src/actions/approve.ts Show resolved Hide resolved
Base automatically changed from fix-esm-memo to master August 22, 2022 22:57
@jordaaash
Copy link
Contributor Author

Also, the node runner for the GitHub action needs to be updated to version 16

Done, thanks! Running now.

joncinque
joncinque previously approved these changes Aug 22, 2022
@mergify mergify bot dismissed joncinque’s stale review August 22, 2022 23:14

Pull request has been modified.

@jordaaash jordaaash merged commit 29d316e into master Aug 23, 2022
@jordaaash jordaaash deleted the fix-esm-token branch August 23, 2022 00:07
@jordaaash
Copy link
Contributor Author

Published in @solana/spl-token@0.3.2

@raymondfeng
Copy link

This change is breaking TypeScript node.js import of @solana/spl-token:

✖ ERROR: Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/@solana/spl-token/lib/cjs/index.js from solana.client.js not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in node_modules/@solana/spl-token/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

@jordaaash
Copy link
Contributor Author

jordaaash commented Aug 24, 2022

@raymondfeng I'm not sure what solana.client.js is or where this error is coming from. Can you open a new issue with details on how to reproduce the issue?

@raymondfeng
Copy link

@jordansexton See #3522. Thank you for the prompt response.

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.

Error to import @solana/spl-token ESM module
3 participants