-
Notifications
You must be signed in to change notification settings - Fork 3
feat: export commonjs and esm from package #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: prerelease | ||
on: | ||
push: | ||
branches: | ||
# releases/<tag>/<version> | ||
# releases/rc.1/2.0.0 - will result in 2.0.0-rc.0 | ||
- releases/*/* | ||
jobs: | ||
prerelease: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
cache: npm | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Install core dependencies | ||
run: npm ci --no-audit | ||
- name: Extract tag and version | ||
id: extract | ||
run: |- | ||
ref=${{ github.ref }} | ||
branch=${ref:11} | ||
tag_version=${branch:9} | ||
tag=${tag_version%/*} | ||
version=${tag_version##*/} | ||
echo "tag=${tag}" >> $GITHUB_OUTPUT | ||
echo "version=${version}" >> $GITHUB_OUTPUT | ||
- name: Log versions | ||
run: |- | ||
echo tag=${{ steps.extract.outputs.tag }} | ||
echo version=${{ steps.extract.outputs.version }} | ||
- name: Setup git user | ||
run: git config --global user.name github-actions | ||
- name: Setup git email | ||
run: git config --global user.email github-actions@github.com | ||
- name: Run npm version | ||
run: npm version ${{ steps.extract.outputs.version }}-${{ steps.extract.outputs.tag }} --allow-same-version | ||
- name: Push changes | ||
run: git push --follow-tags | ||
- name: Run npm publish | ||
run: npm publish --tag=${{ steps.extract.outputs.tag }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env node | ||
import { rm } from 'node:fs/promises' | ||
import { argv } from 'process' | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this an extraneous dependency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because it's a dev dependency 🤷 the lint rule is crazy. Eslint does not know that we don't need it as dependency:
|
||
import { build } from 'tsup' | ||
|
||
const dist = './dist' | ||
|
||
await rm(dist, { recursive: true, force: true }) | ||
|
||
/** @type {import('tsup').Options} */ | ||
const options = { | ||
entry: ['src/main.ts'], | ||
tsconfig: 'tsconfig.json', | ||
bundle: true, | ||
dts: true, | ||
outDir: dist, | ||
watch: argv.includes('--watch'), | ||
} | ||
|
||
await Promise.all(['esm', 'cjs'].map((format) => build({ ...options, format }))) |