Skip to content

Commit

Permalink
feat: bundle as commonjs and release as dual
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Feb 28, 2024
1 parent 411516a commit c79e340
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://unpkg.com/@changesets/config/schema.json",
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "fork-release",
"updateInternalDependencies": "patch",
"ignore": []
}
29 changes: 29 additions & 0 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]
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
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ coverage/
/node_modules
test/baseline*.js
yarn.lock
/index.cjs
1 change: 0 additions & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
29 changes: 23 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (https://wooorm.com)",
"maintainers": [
"JounQin <[email protected]> (https://www.1stG.me)"
],
"contributors": [
"Titus Wormer <[email protected]> (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",
Expand All @@ -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",
Expand Down Expand Up @@ -79,6 +92,10 @@
[
"remark-lint-maximum-heading-length",
false
],
[
"remark-lint-no-multiple-toplevel-headings",
false
]
]
},
Expand Down
20 changes: 20 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit c79e340

Please sign in to comment.