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

SWC-7242 #1565

Merged
merged 1 commit into from
Feb 14, 2025
Merged

SWC-7242 #1565

merged 1 commit into from
Feb 14, 2025

Conversation

nickgros
Copy link
Collaborator

@nickgros nickgros commented Feb 12, 2025

Update our bundle config so that we build and distribute the modules used by SWC. In Sage-Bionetworks/SynapseWebClient#5630 we are adding a bundler to SWC that can handle more modern ESM & CJS code, so we can update synapse-react-client to emit ESM/CJS versions of the same bundle here and later remove the UMD bundle.

  • Update synapse-react-client ESM/CJS bundles to use 'UMD' entry file. SynapseWebClient will use this new bundle in a future change. In the future, we will also replace src/index.ts with the contents of src/umd.index.ts and delete the UMD-specific build processes.
  • Include @sage-bionetworks/synapse-types in the synapse-react-client bundled output since it is prone to drift from the version on NPM, since we do not typically release every @sage-bionetworks/synapse-types change to NPM.

While this is a breaking change, no known applications currently use the synapse-react-client ESM/CJS bundles, so it should be safe.

- Update synapse-react-client ESM/CJS bundles to use 'UMD' entry file. SynapseWebClient will use this new bundle in a future change. In the future, we will also replace `src/index.ts` with the contents of `src/umd.index.ts` and delete the UMD-specific build processes.
- Include @sage-bionetworks/synapse-types in the synapse-react-client bundled output since it is prone to drift from the version on NPM, since we do not typically release every @sage-bionetworks/synapse-types change to NPM.

While this is a breaking change, no known applications currently use the synapse-react-client ESM/CJS bundles, so it should be safe.
@@ -5,15 +5,14 @@ import viteLibraryConfig from './vite-library-config.js'
import vitestConfig from './vitest-config.js'

export class ConfigBuilder {
private includeReactConfig = false
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This can be captured in the existing pluginConfigOptions instance variable, so I removed it.

return this
}

setPluginConfigOptions(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This method was unused.

Comment on lines +31 to +33
externalizeDepsOptions?: Parameters<
typeof getPluginConfig
>[0]['externalizeDepsOptions'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Expose new option to pass arguments to the externalizeDeps plugin.

'@sage-bionetworks/synapse-types',
],
})
.setBuildLibEntry(resolve(__dirname, 'src/umd.index.ts'))
Copy link
Collaborator Author

@nickgros nickgros Feb 12, 2025

Choose a reason for hiding this comment

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

I updated this config to use the umd.index.ts file, which represents "the set of synapse-react-client modules used in SWC", and has nothing to do with the UMD module format. This is a breaking change for any application that retrieves synapse-react-client from NPM and uses the ESM/CJS bundles. However, I do not think that any applications do this today.

In the near future, I plan to make this more clear. I will update file names and (once SynapseWebClient no longer uses it) remove the UMD-specific bundle scripts so we just have one build that creates ESM/CJS packages for SynapseWebClient to consume.

For this PR, I'm just trying to minimize the changes to get this working.

@nickgros nickgros merged commit d3fcd0b into Sage-Bionetworks:main Feb 14, 2025
24 checks passed
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.

2 participants