Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
lukasholzer merged 3 commits into main from feat/provide-cjs-package
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
48 changes: 48 additions & 0 deletions .github/workflows/pre-release.yml
View file Open in desktop
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}}
22 changes: 22 additions & 0 deletions build.mjs
View file Open in desktop
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
Copy link
Member

@eduardoboucas eduardoboucas Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an extraneous dependency?

Copy link
Contributor Author

@lukasholzer lukasholzer Oct 11, 2023

Choose a reason for hiding this comment

The 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:

'tsup' should be listed in the project's dependencies. Run 'npm i -S tsup' to add iteslintimport/no-extraneous-dependencies

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 })))
Loading

AltStyle によって変換されたページ (->オリジナル) /