Skip to content

Commit c04c44a

Browse files
authored
fix: reintroduce package normalisation to nuxt package (#5551)
1 parent c7bbc2a commit c04c44a

4 files changed

Lines changed: 29 additions & 30 deletions

File tree

meta/packages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const packages: PackageManifest[] = [
3434
display: 'Nuxt',
3535
description: 'VueUse Nuxt Module',
3636
manualImport: true,
37-
excludePkgJson: true,
37+
manualEntryPoints: true,
3838
addon: true,
3939
iife: false,
4040
utils: true,

packages/metadata/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ export interface PackageManifest {
1616
target?: string
1717
utils?: boolean
1818
copy?: string[]
19-
// don't change package.json
20-
excludePkgJson?: true
19+
manualEntryPoints?: true
2120
}
2221

2322
export interface VueUseFunction {

scripts/utils.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,7 @@ export async function updateCountBadge(indexes: PackageIndexes) {
232232
export async function updatePackageJSON(indexes: PackageIndexes) {
233233
const { version } = JSON.parse(await fs.readFile('package.json', { encoding: 'utf8' }))
234234

235-
for (const { name, description, author, submodules, iife, excludePkgJson } of packages) {
236-
if (excludePkgJson) {
237-
continue
238-
}
235+
for (const { name, description, author, submodules, iife, manualEntryPoints } of packages) {
239236
const packageDir = join(DIR_SRC, name)
240237
const packageJSONPath = join(packageDir, 'package.json')
241238
const packageJSON = JSON.parse(await fs.readFile(packageJSONPath, { encoding: 'utf8' }))
@@ -255,32 +252,35 @@ export async function updatePackageJSON(indexes: PackageIndexes) {
255252
url: 'git+https://github.com/vueuse/vueuse.git',
256253
directory: `packages/${name}`,
257254
}
258-
packageJSON.main = './dist/index.js'
259-
packageJSON.types = './dist/index.d.ts'
260-
packageJSON.module = './dist/index.js'
261-
if (iife !== false) {
262-
packageJSON.unpkg = './dist/index.iife.min.js'
263-
packageJSON.jsdelivr = './dist/index.iife.min.js'
264-
}
265255
packageJSON.files = [
266256
'dist',
267257
]
268258

269-
packageJSON.exports = {
270-
'.': './dist/index.js',
271-
...packageJSON.exports,
272-
'./*': './dist/*',
273-
}
274-
275-
if (submodules) {
276-
indexes.functions
277-
.filter(i => i.package === name)
278-
.forEach((i) => {
279-
packageJSON.exports[`./${i.name}`] = `./dist/${i.name}.js`
280-
if (i.component) {
281-
packageJSON.exports[`./${i.name}/component`] = `./dist/${i.name}/component.js`
282-
}
283-
})
259+
if (!manualEntryPoints) {
260+
packageJSON.main = './dist/index.js'
261+
packageJSON.types = './dist/index.d.ts'
262+
packageJSON.module = './dist/index.js'
263+
if (iife !== false) {
264+
packageJSON.unpkg = './dist/index.iife.min.js'
265+
packageJSON.jsdelivr = './dist/index.iife.min.js'
266+
}
267+
268+
packageJSON.exports = {
269+
'.': './dist/index.js',
270+
...packageJSON.exports,
271+
'./*': './dist/*',
272+
}
273+
274+
if (submodules) {
275+
indexes.functions
276+
.filter(i => i.package === name)
277+
.forEach((i) => {
278+
packageJSON.exports[`./${i.name}`] = `./dist/${i.name}.js`
279+
if (i.component) {
280+
packageJSON.exports[`./${i.name}/component`] = `./dist/${i.name}/component.js`
281+
}
282+
})
283+
}
284284
}
285285

286286
await fs.writeFile(packageJSONPath, `${JSON.stringify(packageJSON, null, 2)}\n`)

test/__snapshots__/tsnapi/@vueuse/metadata/index.snapshot.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface PackageManifest {
4141
target?: string;
4242
utils?: boolean;
4343
copy?: string[];
44-
excludePkgJson?: true;
44+
manualEntryPoints?: true;
4545
}
4646
export interface VueUseFunction {
4747
name: string;

0 commit comments

Comments
 (0)