Skip to content
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

fix: change the build config to bundle deps correctly, fix #111 #112

Merged
merged 6 commits into from
Apr 16, 2024
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
11 changes: 11 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ export default defineBuildConfig({
],
rollup: {
inlineDependencies: true,
json: {
compact: true,
namedExports: false,
preferConst: false,
},
commonjs: {
requireReturnsDefault: 'auto',
},
dts: {
respectExternal: false,
},
},
clean: true,
declaration: true,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"typecheck": "tsc",
"prepublishOnly": "nr build",
"release": "bumpp && pnpm publish --no-git-checks",
"test": "vitest"
"test": "unbuild && vitest"
Copy link
Contributor Author

@SukkaW SukkaW Apr 16, 2024

Choose a reason for hiding this comment

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

The new test case is against the dist, so the dist needs to be built before the test happens.

},
"dependencies": {
"@antfu/ni": "^0.21.12",
Expand All @@ -41,7 +41,6 @@
"execa": "^8.0.1",
"picocolors": "^1.0.0",
"prompts": "^2.4.2",
"semver": "^7.6.0",
"ufo": "^1.5.3",
"unconfig": "^0.3.13",
"yargs": "^17.7.2"
Expand All @@ -67,6 +66,7 @@
"npm-package-arg": "^11.0.2",
"npm-registry-fetch": "^16.2.1",
"rimraf": "^5.0.5",
"semver": "^7.6.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

semver is a CommonJS module and a dependency of both taze and taze's dependency.

Rollup has trouble handling a CommonJS external from a transitive dependency, so let's bundle semver as well.

"taze": "workspace:*",
"typescript": "^5.4.5",
"unbuild": "^2.0.0",
Expand Down
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Argv } from 'yargs'
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import c from 'picocolors'
import { version } from '../package.json'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we've disabled the @rollup/plugin-json's namedExports optimization, we can't use named import here.

import pkgJson from '../package.json'
import { check } from './commands/check'
import { usage } from './commands/usage'
import { resolveConfig } from './config'
Expand Down Expand Up @@ -142,7 +142,7 @@ yargs(hideBin(process.argv))
)
.showHelpOnFail(false)
.alias('h', 'help')
.version('version', version)
.version('version', pkgJson.version)
.alias('v', 'version')
.help()
.argv
11 changes: 11 additions & 0 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import path from 'node:path'
import { expect, it } from 'vitest'
import { execa } from 'execa'

it('taze cli should just works', async () => {
const binPath = path.resolve(__dirname, '../bin/taze.mjs')

const proc = await execa(process.execPath, [binPath], { stdio: 'pipe' })

expect(proc.stderr).toBe('')
})
Loading