https://github.com/mischnic/parcel-resolver-dual-default
https://github.com/mischnic/parcel-resolver-dual-default
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mischnic/parcel-resolver-dual-default
- Owner: mischnic
- Created: 2022-11-25T21:22:19.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-25T21:27:46.000Z (about 3 years ago)
- Last Synced: 2025-01-26T07:11:32.172Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `parcel-resolver-dual-default`
Example for a Parcel 2 resolver that wraps your entrypoint so that `(await import("x")).default === require("x")` (as opposed to having to do `require("x").default`).
This works by replacing the entrypoint with an asset that does `import v from "actual entrypoint"; module.exports = v;`
You'd only need to add this `.parcelrc`
```json
{
"extends": "@parcel/config-default",
"resolvers": ["parcel-resolver-dual-default", "..."]
}
```
Then building
```js
export default 1;
```
will result in bundles that behave like this:
```js
import a from "./dist/index.mjs";
const b = require("./dist/index.cjs");
assert(a === 1);
assert(b === 1);
```