Support default export and UMD#301
Merged
Merged
Conversation
It’s possible to support both a CJS export and a `.default` property by
defining the export as an interface that has a call expression and a
default property. This makes it possible to use
`import classNames from 'classnames'` or `classNames.default('')`.
Also this packages exposes a UMD module, meaning `classNames` is
available as a global when using a TypeScript script, but not when using
a TypeScript module. This is supported by adding
`export as namespace classNames`.
5c3853e to
aa1a0fa
Compare
Collaborator
|
Thanks @remcohaszing 💙 |
CrispyBaguette
pushed a commit
to CrispyBaguette/wasm-palette-converter
that referenced
this pull request
Nov 8, 2024
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [classnames](https://github.com/JedWatson/classnames) | dependencies | minor | [`2.3.1` -> `2.5.1`](https://renovatebot.com/diffs/npm/classnames/2.3.1/2.5.1) | --- ### Release Notes <details> <summary>JedWatson/classnames (classnames)</summary> ### [`v2.5.1`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v251--2023-12-29) [Compare Source](JedWatson/classnames@v2.5.0...v2.5.1) - Remove `workspaces` field from package ([#​350](JedWatson/classnames#350)) ### [`v2.5.0`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v250--2023-12-27) [Compare Source](JedWatson/classnames@v2.4.0...v2.5.0) - Restore ability to pass a TypeScript `interface` ([#​341](JedWatson/classnames#341)) - Add `exports` field to package ([#​342](JedWatson/classnames#342)) ### [`v2.4.0`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v240--2023-12-26) [Compare Source](JedWatson/classnames@v2.3.3...v2.4.0) - Use string concatenation to increase performance thanks [Jon Koops](https://github.com/jonkoops) ([#​336](JedWatson/classnames#336)) ### [`v2.3.3`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v233--2023-12-21) [Compare Source](JedWatson/classnames@v2.3.2...v2.3.3) - Fix default export, thanks [Remco Haszing](https://github.com/remcohaszing) ([#​301](JedWatson/classnames#301)) - Fix types for read-only arrays, thanks [Ben Thompson](https://github.com/BenGearset) ([#​307](JedWatson/classnames#307)) - Replace README examples with functional-style components, thanks [JoeDGit](https://github.com/JoeDGit) ([#​303](JedWatson/classnames#303)) ### [`v2.3.2`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v232--2022-09-13) [Compare Source](JedWatson/classnames@v2.3.1...v2.3.2) - Fix TypeScript types when using require, thanks [Mark Dalgleish](https://github.com/markdalgleish) ([#​276](JedWatson/classnames#276)) - Fix toString as `[Object object]` in a vm, thanks [Remco Haszing](https://github.com/remcohaszing) ([#​281](JedWatson/classnames#281)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xNDIuNSIsInVwZGF0ZWRJblZlciI6IjM4LjE0Mi41IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> Reviewed-on: https://gitea.bruyant.xyz/alexandre/PaletteSwitcher/pulls/48 Co-authored-by: Renovate <renovate@bruyant.xyz> Co-committed-by: Renovate <renovate@bruyant.xyz>
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.
It’s possible to support both a CJS export and a
.defaultproperty by defining the export as an interface that has a call expression and a default property. This makes it possible to useimport classNames from 'classnames'orclassNames.default('').Also this packages exposes a UMD module, meaning
classNamesis available as a global when using a TypeScript script, but not when using a TypeScript module. This is supported by addingexport as namespace classNames.Technically this also declares it’s valid to use
classNames.defaultwhen usingclassNamesas a global. It may be better to move the lineclassNames.default = classNamesoutside of the if-statement at runtime.