Skip to content

Commit 3e3333a

Browse files
authored
feat: add hoistDependencies (#1)
1 parent e0c5609 commit 3e3333a

File tree

11 files changed

+8049
-592
lines changed

11 files changed

+8049
-592
lines changed

.github/workflows/preview-release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: preview release
2+
on:
3+
push:
4+
branches:
5+
- '**'
6+
tags:
7+
- '!**'
8+
pull_request:
9+
types: [opened, synchronize, labeled]
10+
branches: [main]
11+
paths-ignore:
12+
- 'docs/**'
13+
- 'test/**'
14+
- 'specs/**'
15+
- 'playground/**'
16+
17+
jobs:
18+
release:
19+
if: ${{ contains(github.event.pull_request.labels.*.name, 'cr-tracked') }}
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
28+
29+
- name: Setup node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: lts/*
33+
cache: pnpm
34+
35+
- name: Install dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Build
39+
run: pnpm build
40+
41+
- name: Release with pkg-pr-new
42+
run: pnpx pkg-pr-new publish --no-template --pnpm

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permissions:
66
on:
77
push:
88
tags:
9-
- 'v*'
9+
- "v*"
1010

1111
jobs:
1212
release:
@@ -22,4 +22,4 @@ jobs:
2222

2323
- run: npx changelogithub
2424
env:
25-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ node_modules
4141
# Test output
4242
/.nyc_output
4343
/coverage
44-
dist
44+
dist
45+
.env

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,31 @@
88
99
A collection of utility functions for Nuxt module authors.
1010

11-
1211
## Installation
1312

1413
```bash
1514
npm i nuxt-module-utils
1615
```
1716

18-
<!-- ## Usage
17+
## Usage
18+
19+
### `hoistDependencies(hoist: string[])`
20+
21+
While Nuxt provides the `typescript.hoist` option to generate aliases for nested dependencies within pnpm monorepos, it is processed before modules are set up.
22+
23+
The `hoistDependencies` utility allows you to hoist dependencies from within your module's `setup` function. It works by resolving the paths of the specified packages and adding them to Nuxt's TypeScript configuration, ensuring they are included in the generated `tsconfig.json`.
1924

2025
```ts
2126
// src/module.ts
22-
import { someUtil } from 'nuxt-module-utils'
27+
import { defineNuxtModule } from '@nuxt/kit'
28+
import { hoistDependencies } from 'nuxt-module-utils'
2329

2430
export default defineNuxtModule({
25-
setup() {
31+
async setup() {
32+
await hoistDependencies(['my-lib', 'my-other-lib'])
2633
}
2734
})
28-
``` -->
35+
```
2936

3037
## Sponsors
3138

@@ -34,4 +41,3 @@ export default defineNuxtModule({
3441
<img src="https://raw.githubusercontent.com/bobbiegoede/static/main/sponsors.svg" />
3542
</a>
3643
</p>
37-

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
"type": "module",
66
"license": "MIT",
77
"funding": "https://github.com/sponsors/bobbiegoede",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/bobbiegoede/nuxt-module-utils.git"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/bobbiegoede/nuxt-module-utils/issues"
14+
},
815
"keywords": [
916
"nuxt",
1017
"module"
@@ -34,9 +41,22 @@
3441
},
3542
"packageManager": "pnpm@10.11.1",
3643
"devDependencies": {
37-
"@nuxt/kit": "^3.17.5",
44+
"@types/node": "^24.0.13",
3845
"bumpp": "^10.1.1",
3946
"tsdown": "^0.12.7",
4047
"typescript": "^5.8.3"
48+
},
49+
"peerDependencies": {
50+
"nuxt": "^3.16.0 || ^4.0.0-rc.0",
51+
"@nuxt/kit": "^3.16.0 || ^4.0.0-rc.0",
52+
"@nuxt/schema": "^3.16.0 || ^4.0.0-rc.0"
53+
},
54+
"dependencies": {
55+
"defu": "^6.1.4",
56+
"exsolve": "^1.0.7",
57+
"magic-string": "^0.30.17",
58+
"pathe": "^2.0.3",
59+
"pkg-types": "^2.2.0",
60+
"unplugin": "^2.3.5"
4161
}
4262
}

0 commit comments

Comments
 (0)