Skip to content

Commit

Permalink
Merge remote-tracking branch 'egoist/dev' into ocavue/prettier-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue committed Nov 19, 2023
2 parents 35c54ef + 4c1ad38 commit 1c921ed
Show file tree
Hide file tree
Showing 9 changed files with 590 additions and 72 deletions.
59 changes: 24 additions & 35 deletions .github/workflows/ci.yml
Expand Up @@ -8,68 +8,57 @@ on:

jobs:
test:
if: "!contains(github.event.head_commit.message, 'ci skip')"

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [16.x, 18.x]
node-version: [18.x, 20.x]

runs-on: ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2
name: Install pnpm

- name: Cache ~/.pnpm-store
uses: actions/cache@v3
env:
cache-name: cache-pnpm-store
- uses: actions/setup-node@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ matrix.node-version }}-test-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-test-${{ env.cache-name }}-
${{ runner.os }}-${{ matrix.node-version }}-test-
${{ runner.os }}-
- name: Install pnpm
run: corepack enable
node-version: ${{ matrix.node-version }}
cache: pnpm

- name: Install deps
run: pnpm i

# Runs a set of commands using the runners shell
- name: Build and Test
run: npm test
run: pnpm test

release:
runs-on: ubuntu-latest
needs: ['test']
if: "!contains(github.event.head_commit.message, 'skip-release') && !contains(github.event.head_commit.message, 'skip-ci') && github.event_name != 'pull_request'"
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Cache ~/.pnpm-store
uses: actions/cache@v3
env:
cache-name: cache-pnpm-store
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
name: Install pnpm

- uses: actions/setup-node@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ matrix.node-version }}-release-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-release-${{ env.cache-name }}-
${{ runner.os }}-${{ matrix.node-version }}-release-
${{ runner.os }}-
- run: corepack enable
node-version: lts/*
cache: pnpm

- run: pnpm i

- run: pnpx semantic-release --branches main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -16,6 +16,8 @@ Install it locally in your project folder:
npm i tsup -D
# Or Yarn
yarn add tsup --dev
# Or pnpm
pnpm add tsup -D
```

You can also install it globally but it's not recommended.
Expand Down
18 changes: 18 additions & 0 deletions docs/README.md
Expand Up @@ -28,6 +28,8 @@ Install it locally in your project folder:
npm i tsup -D
# Or Yarn
yarn add tsup --dev
# Or pnpm
pnpm add tsup -D
```

You can also install it globally but it's not recommended.
Expand Down Expand Up @@ -579,6 +581,22 @@ Use `--publicDir` flag to copy files inside `./public` folder to the output dire

You can also specify a custom directory using `--publicDir another-directory`.

### JavaScript API

If you want to use `tsup` in your Node.js program, you can use the JavaScript API:

```js
import { build } from 'tsup'

await build({
entry: ['src/index.ts'],
sourcemap: true,
dts: true,
})
```

For all available options for the `build` function, please see [the API docs](https://paka.dev/npm/tsup).

## Troubleshooting

### error: No matching export in "xxx.ts" for import "xxx"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -97,5 +97,5 @@
"engines": {
"node": ">=18"
},
"packageManager": "pnpm@8.6.0"
"packageManager": "pnpm@8.10.5"
}
2 changes: 1 addition & 1 deletion src/esbuild/postcss.ts
Expand Up @@ -103,7 +103,7 @@ export const postcssPlugin = ({
}

// Transform CSS
const result = postcss
const result = await postcss
?.default(plugins)
.process(contents, { ...options, from: args.path })

Expand Down
5 changes: 5 additions & 0 deletions test/__snapshots__/index.test.ts.snap
Expand Up @@ -552,3 +552,8 @@ exports[`support baseUrl and paths in tsconfig.json in --dts-resolve build 1`] =
export { foo };
"
`;
exports[`support tailwindcss postcss plugin 1`] = `
"\\"use strict\\";
"
`;
23 changes: 23 additions & 0 deletions test/index.test.ts
Expand Up @@ -337,6 +337,29 @@ test('import css', async () => {
expect(outFiles).toEqual(['input.css', 'input.js'])
})

test('support tailwindcss postcss plugin', async () => {
const { output, outFiles } = await run(getTestName(), {
'input.ts': `
import './foo.css'
`,
'postcss.config.js': `
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
}
}
`,
'foo.css': `
@tailwind base;
@tailwind components;
@tailwind utilities;
`,
})
expect(output).toMatchSnapshot()
expect(outFiles).toEqual(['input.css', 'input.js'])
})

test('import css in --dts', async () => {
const { output, outFiles } = await run(
getTestName(),
Expand Down
2 changes: 2 additions & 0 deletions test/package.json
Expand Up @@ -4,11 +4,13 @@
"@egoist/path-parser": "1.0.4",
"@types/react": "17.0.50",
"@types/react-dom": "17.0.17",
"autoprefixer": "10.4.16",
"graphql": "^15.3.0",
"graphql-tools": "^5.0.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-select": "5.7.0",
"tailwindcss": "3.3.5",
"vue": "3.2.36",
"vue-router": "4.0.15"
},
Expand Down

0 comments on commit 1c921ed

Please sign in to comment.