Skip to content

Commit 03f703e

Browse files
committed
feat: bundle as commonjs and release as dual
1 parent 88a0e38 commit 03f703e

File tree

9 files changed

+130
-7
lines changed

9 files changed

+130
-7
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config/schema.json",
3+
"commit": false,
4+
"linked": [],
5+
"access": "public",
6+
"baseBranch": "fork-release",
7+
"updateInternalDependencies": "patch",
8+
"ignore": []
9+
}

.github/workflows/rebase.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Rebase
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
rebase:
10+
name: Rebase and Push
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Repo
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
ref: fork-release
18+
19+
- name: Set Git Info
20+
run: |
21+
git config --global user.email admin@1stg.me
22+
git config --global user.name JounQin
23+
git remote add upstream https://github.com/wooorm/import-meta-resolve.git
24+
25+
- name: Rebase and Push
26+
run: |
27+
git fetch upstream main:main
28+
git rebase upstream/main
29+
git push -f

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- fork-release
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
pull-requests: write
12+
13+
jobs:
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v4
20+
with:
21+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js LTS
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 24
28+
29+
- name: Install Dependencies
30+
run: npm install
31+
32+
- name: Publish to npm
33+
uses: changesets/action@v1
34+
with:
35+
publish: npx @changesets/cli publish
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Sync to cnpm
40+
run: npx cnpm sync @dual-bundle/import-meta-resolve

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
coverage/
88
test/baseline*.js
99
yarn.lock
10+
/index.cjs

.remarkignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.changeset

package.json

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
22
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
33
"bugs": "https://github.com/wooorm/import-meta-resolve/issues",
4+
"maintainers": [
5+
"JounQin <admin@1stg.me> (https://www.1stG.me)"
6+
],
47
"contributors": [
58
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
69
],
7-
"description": "Resolve things like Node.js — ponyfill for `import.meta.resolve`",
10+
"description": "A fork of `import-meta-resolve` with commonjs + ESM support at the same time, AKA dual package.",
811
"devDependencies": {
912
"@types/node": "^24.0.0",
1013
"@types/semver": "^7.0.0",
1114
"c8": "^10.0.0",
15+
"esbuild": "^0.25.9",
1216
"f-ck": "^2.0.0",
1317
"prettier": "^3.0.0",
1418
"remark-cli": "^12.0.0",
@@ -21,12 +25,13 @@
2125
"files": [
2226
"index.d.ts.map",
2327
"index.d.ts",
28+
"index.cjs",
2429
"index.js",
2530
"lib/"
2631
],
2732
"funding": {
2833
"type": "github",
29-
"url": "https://github.com/sponsors/wooorm"
34+
"url": "https://github.com/sponsors/JounQin"
3035
},
3136
"keywords": [
3237
"esm",
@@ -35,8 +40,14 @@
3540
"resolve"
3641
],
3742
"license": "MIT",
38-
"main": "index.js",
39-
"name": "import-meta-resolve",
43+
"main": "index.cjs",
44+
"module": "index.js",
45+
"exports": {
46+
"types": "./index.d.ts",
47+
"require": "./index.cjs",
48+
"default": "./index.js"
49+
},
50+
"name": "@dual-bundle/import-meta-resolve",
4051
"prettier": {
4152
"bracketSpacing": false,
4253
"semi": false,
@@ -51,12 +62,16 @@
5162
[
5263
"remark-lint-maximum-heading-length",
5364
false
65+
],
66+
[
67+
"remark-lint-no-multiple-toplevel-headings",
68+
false
5469
]
5570
]
5671
},
57-
"repository": "wooorm/import-meta-resolve",
72+
"repository": "un-es/import-meta-resolve",
5873
"scripts": {
59-
"build": "tsc --build --clean && tsc --build && type-coverage",
74+
"build": "tsc --build --clean && tsc --build && type-coverage && esbuild --bundle --outfile=index.cjs --platform=node --format=cjs index.js",
6075
"format": "remark --frail --quiet --output -- . && prettier --write --log-level warn -- . && xo --fix",
6176
"generate": "node --conditions development script.js",
6277
"prepack": "npm run generate && npm run build && npm run format",

readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# `@dual-bundle/import-meta-resolve`
2+
3+
A fork of [`import-meta-resolve`](https://github.com/wooorm/import-meta-resolve)
4+
with commonjs + ESM support at the same time, AKA dual package.
5+
6+
It will rebase and try to release in order to sync with the upstream every day,
7+
see [.github/workflows/rebase.yml](.github/workflows/rebase.yml) for details.
8+
9+
## Installation
10+
11+
```bash
12+
# npm
13+
npm install @dual-bundle/import-meta-resolve
14+
15+
# yarn
16+
yarn add @dual-bundle/import-meta-resolve
17+
```
18+
19+
***
20+
121
# import-meta-resolve
222

323
[![Build][build-badge]][build]

test/ponyfill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {resolve} from '../index.js'
44

55
test('ponyfill', async function () {
66
assert.deepEqual(
7-
Object.keys(await import('import-meta-resolve')).sort(),
7+
Object.keys(await import('@dual-bundle/import-meta-resolve')).sort(),
88
['moduleResolve', 'resolve'],
99
'should expose the public api'
1010
)

0 commit comments

Comments
 (0)