diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..e5b6d8d --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..29c7d32 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://unpkg.com/@changesets/config/schema.json", + "commit": false, + "linked": [], + "access": "public", + "baseBranch": "fork-release", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 0000000..66f58f4 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,29 @@ +name: Rebase + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +jobs: + rebase: + name: Rebase and Push + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: fork-release + + - name: Set Git Info + run: | + git config --global user.email admin@1stg.me + git config --global user.name JounQin + git remote add upstream https://github.com/wooorm/import-meta-resolve.git + + - name: Rebase and Push + run: | + git fetch upstream main:main + git rebase upstream/main + git push -f diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3ba5a98 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Release + +on: + push: + branches: + - fork-release + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + fetch-depth: 0 + + - name: Setup Node.js LTS + uses: actions/setup-node@v4 + with: + node-version: lts/* + + - name: Install Dependencies + run: npm install + + - name: Publish to npm + uses: changesets/action@v1 + with: + publish: npx @changesets/cli publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Sync to cnpm + run: npx cnpm sync @dual-bundle/import-meta-resolve diff --git a/.gitignore b/.gitignore index ac6d815..8416fa3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ coverage/ /node_modules test/baseline*.js yarn.lock +/index.cjs diff --git a/lib/errors.js b/lib/errors.js index 66e026e..7a032cd 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -385,7 +385,6 @@ function isErrorStackTraceLimitWritable() { // Do no touch Error.stackTraceLimit as V8 would attempt to install // it again during deserialization. try { - // @ts-expect-error: not in types? if (v8.startupSnapshot.isBuildingSnapshot()) { return false } diff --git a/package.json b/package.json index 75b229b..3bbd085 100644 --- a/package.json +++ b/package.json @@ -1,37 +1,50 @@ { - "name": "import-meta-resolve", + "name": "@dual-bundle/import-meta-resolve", "version": "4.0.0", - "description": "Resolve things like Node.js — ponyfill for `import.meta.resolve`", + "description": "A fork of `import-meta-resolve` with commonjs + ESM support at the same time, AKA dual package.", "license": "MIT", "keywords": [ "resolve", "node", "esm", - "module" + "module", + "import", + "import-meta-resolve" ], - "repository": "wooorm/import-meta-resolve", + "repository": "un-es/import-meta-resolve", "bugs": "https://github.com/wooorm/import-meta-resolve/issues", "funding": { "type": "github", "url": "https://github.com/sponsors/wooorm" }, "author": "Titus Wormer (https://wooorm.com)", + "maintainers": [ + "JounQin (https://www.1stG.me)" + ], "contributors": [ "Titus Wormer (https://wooorm.com)" ], "sideEffects": false, "type": "module", - "main": "index.js", + "main": "index.cjs", + "module": "index.js", "types": "index.d.ts", + "exports": { + "types": "./index.d.ts", + "require": "./index.cjs", + "default": "./index.js" + }, "files": [ "lib/", "index.d.ts", + "index.cjs", "index.js" ], "devDependencies": { "@types/node": "^20.0.0", "@types/semver": "^7.0.0", "c8": "^8.0.0", + "esbuild": "^0.20.1", "prettier": "^3.0.0", "remark-cli": "^11.0.0", "remark-preset-wooorm": "^9.0.0", @@ -43,7 +56,7 @@ "scripts": { "prepack": "npm run generate && npm run build && npm run format", "generate": "node --conditions development script.js", - "build": "tsc --build --clean && tsc --build && type-coverage", + "build": "tsc --build --clean && tsc --build && type-coverage && esbuild --bundle --outfile=index.cjs --platform=node --format=cjs index.js", "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", "test-api": "node --experimental-import-meta-resolve test/baseline.js && node --experimental-import-meta-resolve test/baseline-async.js && node test/index.js", "test-coverage": "c8 --check-coverage --branches 75 --functions 75 --lines 75 --statements 75 --reporter lcov npm run test-api", @@ -79,6 +92,10 @@ [ "remark-lint-maximum-heading-length", false + ], + [ + "remark-lint-no-multiple-toplevel-headings", + false ] ] }, diff --git a/readme.md b/readme.md index f4574d7..700c0f7 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,23 @@ +# `@dual-bundle/import-meta-resolve` + +A fork of [`import-meta-resolve`](https://github.com/wooorm/import-meta-resolve) +with commonjs + ESM support at the same time, AKA dual package. + +It will rebase and try to release in order to sync with the upstream every day, +see [.github/workflows/rebase.yml](.github/workflows/rebase.yml) for details. + +## Installation + +```bash +# npm +npm install @dual-bundle/import-meta-resolve + +# yarn +yarn add @dual-bundle/import-meta-resolve +``` + +*** + # import-meta-resolve [![Build][build-badge]][build]