Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/char0n/swagger-ui-parcel
POC of integrating SwaggerUI with Parcel.js
https://github.com/char0n/swagger-ui-parcel
parcel parceljs swagger-ui
Last synced: 1 day ago
JSON representation
POC of integrating SwaggerUI with Parcel.js
- Host: GitHub
- URL: https://github.com/char0n/swagger-ui-parcel
- Owner: char0n
- License: apache-2.0
- Created: 2022-06-02T12:33:11.000Z (over 2 years ago)
- Default Branch: swagger-ui
- Last Pushed: 2024-01-08T14:42:24.000Z (about 1 year ago)
- Last Synced: 2024-10-06T01:21:47.846Z (4 months ago)
- Topics: parcel, parceljs, swagger-ui
- Language: HTML
- Homepage:
- Size: 234 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Using Parcel to build SwaggerUI
## JavaScript
Parcel.js module resolution is not compliant with the spec.
```js
import * as e from 'lodash/memoize.js';
```Parcel.js resolves to:
```
[Function: memoize] { Cache: [Function: MapCache] }
```The rest of the bundlers and Node.js resolves to:
```
[Module: null prototype] {
default: [Function: memoize] { Cache: [Function: MapCache] }
}
```It seems that Parcel.js resolves default export to the symbol the default export points to
instead of resolving to Module Object.Related issues:
- https://github.com/parcel-bundler/parcel/issues/5459
- https://github.com/thangngoc89/bs-ant-design/issues/21To resolve the issue with the latest version of `[email protected]`
following Parcel.js alias needs to provided in `package.json`:```json
{
"alias": {
"./node_modules/swagger-ui/dist/swagger-ui-es-bundle-core.js": "./node_modules/swagger-ui/dist/swagger-ui.js"
}
}
```Using this setup we avoid using modern ESM distribution fragments and instead
fallback to CommonJS which consistently works with Parcel.js.## Support for package.json `exports` field
Parcel.js doesn't support package.json [exports](https://nodejs.org/api/packages.html#package-entry-points) field [by default](https://parceljs.org/blog/v2-9-0/#new-resolver). It needs to be enabled
explicitly. This can be done by adding the following to your project root package.json:```json
{
"@parcel/resolver-default": {
"packageExports": true
}
}
```