Skip to content

Commit 09095f2

Browse files
committed
refactor: project rewrite p2
- re-implement logging - allow `esbuild` plugin to be disabled Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 87bc625 commit 09095f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+768
-277
lines changed

__fixtures__/pkg/reverse/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"resolveJsonModule": true,
1919
"sourceMap": true,
2020
"target": "es2024",
21-
"traceResolution": true,
2221
"verbatimModuleSyntax": true
2322
},
2423
"exclude": ["coverage", "dist", "node_modules"],

__tests__/reporters/verbose.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* @see https://vitest.dev/advanced/reporters#exported-reporters
55
*/
66

7+
import colors, { type Colors } from '@flex-development/colors'
78
import type { Task, TaskResultPack } from '@vitest/runner'
89
import { getNames, getTests } from '@vitest/runner/utils'
9-
import colors, { type Colors } from 'tinyrainbow'
1010
import type { RunnerTask, RunnerTestFile } from 'vitest'
1111
import type { ConfigEnv } from 'vitest/config'
1212
import { DefaultReporter, type Reporter } from 'vitest/reporters'

eslint.base.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ export default [
633633
'no-redeclare': 0,
634634
'no-restricted-imports': 0,
635635
'no-return-await': 0,
636+
'no-setter-return': 0,
636637
'no-shadow': 0,
637638
'no-sparse-arrays': 0,
638639
'no-throw-literal': 0,

eslint.config.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ export default [
2929
]
3030
},
3131
{
32-
files: ['src/providers/logger.service.mts'],
32+
files: ['**/*.+(cts|mts|ts|tsx)'],
33+
ignores: ['**/*.{md,mdx}/*.+(cts|mts|ts|tsx)'],
3334
rules: {
34-
'@typescript-eslint/unified-signatures': 0
35+
'@typescript-eslint/only-throw-error': [2, { allow: ['Failure'] }]
3536
}
3637
}
3738
]

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"@flex-development/errnode": "3.1.1",
141141
"@flex-development/fst-util-from-fs": "1.0.0-alpha.1",
142142
"@flex-development/is-builtin": "3.2.0",
143+
"@flex-development/log": "flex-development/log#commit=194e98812fbbffceb6e2158b849706c597175207",
143144
"@flex-development/mlly": "1.0.0-alpha.20",
144145
"@flex-development/pathe": "4.0.1",
145146
"@flex-development/tsconfig-types": "5.1.0",
@@ -151,7 +152,7 @@
151152
"devlop": "1.1.0",
152153
"json5": "2.2.3",
153154
"magic-string": "0.30.17",
154-
"rollup": "4.31.0",
155+
"rollup": "4.34.4",
155156
"smob": "1.5.0"
156157
},
157158
"devDependencies": {
@@ -175,7 +176,7 @@
175176
"@types/eslint": "9.6.1",
176177
"@types/eslint__js": "8.42.3",
177178
"@types/is-ci": "3.0.4",
178-
"@types/node": "22.10.7",
179+
"@types/node": "22.13.1",
179180
"@types/node-notifier": "8.0.5",
180181
"@typescript-eslint/eslint-plugin": "8.21.1-alpha.2",
181182
"@typescript-eslint/parser": "8.21.1-alpha.2",

src/__tests__/make.spec.mts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,6 @@ describe('unit:make', () => {
1818
...Parameters<typeof testSubject>,
1919
Fn<Parameters<typeof testSubject>, Fn<[Report], undefined>>?
2020
]>([
21-
[
22-
null,
23-
function assertion(this: void): Fn<[Report], undefined> {
24-
return assert
25-
26-
/**
27-
* @this {void}
28-
*
29-
* @param {Report} report
30-
* Build report
31-
* @return {undefined}
32-
*/
33-
function assert(report: Report): undefined {
34-
return void expect(report).to.have.property('builds').be.of.length(0)
35-
}
36-
}
37-
],
3821
[
3922
reverse,
4023
function assertion(this: void): Fn<[Report], undefined> {
@@ -80,7 +63,7 @@ describe('unit:make', () => {
8063
assert = constant(constant(undefined))
8164
) => {
8265
// Act
83-
const result = await testSubject(config)
66+
const result = await testSubject({ ...config, logLevel: 'silent' })
8467

8568
// Expect
8669
expect(result).to.satisfy(isObjectPlain)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @file Type Tests - Failure
3+
* @module mkbuild/interfaces/tests/unit-d/Failure
4+
*/
5+
6+
import type TestSubject from '#interfaces/failure'
7+
import type { Message } from '@flex-development/mkbuild'
8+
9+
describe('unit-d:interfaces/Failure', () => {
10+
it('should extend Message', () => {
11+
expectTypeOf<TestSubject>().toMatchTypeOf<Message>()
12+
})
13+
14+
it('should match [level: "error"]', () => {
15+
expectTypeOf<TestSubject>().toHaveProperty('level').toEqualTypeOf<'error'>()
16+
})
17+
})

src/interfaces/__tests__/message.spec-d.mts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
*/
55

66
import type TestSubject from '#interfaces/message'
7-
import type { MessageLocation, RollupCode } from '@flex-development/mkbuild'
7+
import type {
8+
LogType,
9+
MessageLocation,
10+
RollupCode
11+
} from '@flex-development/mkbuild'
812
import type { Nilable } from '@flex-development/tutils'
9-
import type * as rollup from 'rollup'
1013

1114
describe('unit-d:interfaces/Message', () => {
1215
it('should match [binding?: string | null | undefined]', () => {
@@ -19,10 +22,10 @@ describe('unit-d:interfaces/Message', () => {
1922
expectTypeOf<TestSubject>().toHaveProperty('cause').toEqualTypeOf<unknown>()
2023
})
2124

22-
it('should match [code: RollupCode]', () => {
25+
it('should match [code?: RollupCode | null | undefined]', () => {
2326
expectTypeOf<TestSubject>()
2427
.toHaveProperty('code')
25-
.toEqualTypeOf<RollupCode>()
28+
.toEqualTypeOf<Nilable<RollupCode>>()
2629
})
2730

2831
it('should match [exporter?: string | null | undefined]', () => {
@@ -61,10 +64,14 @@ describe('unit-d:interfaces/Message', () => {
6164
.toEqualTypeOf<Nilable<MessageLocation>>()
6265
})
6366

64-
it('should match [level: rollup.LogLevel]', () => {
67+
it('should match [level: LogType]', () => {
68+
expectTypeOf<TestSubject>().toHaveProperty('level').toEqualTypeOf<LogType>()
69+
})
70+
71+
it('should match [message: string]', () => {
6572
expectTypeOf<TestSubject>()
66-
.toHaveProperty('level')
67-
.toEqualTypeOf<rollup.LogLevel>()
73+
.toHaveProperty('message')
74+
.toEqualTypeOf<string>()
6875
})
6976

7077
it('should match [meta?: unknown]', () => {
@@ -107,10 +114,6 @@ describe('unit-d:interfaces/Message', () => {
107114
.toEqualTypeOf<Nilable<string>>()
108115
})
109116

110-
it('should match [text: string]', () => {
111-
expectTypeOf<TestSubject>().toHaveProperty('text').toEqualTypeOf<string>()
112-
})
113-
114117
it('should match [url?: string | null | undefined]', () => {
115118
expectTypeOf<TestSubject>()
116119
.toHaveProperty('url')

src/interfaces/__tests__/result.spec-d.mts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*/
55

66
import type TestSubject from '#interfaces/result'
7+
import type { Logger } from '@flex-development/log'
78
import type {
9+
Failure,
810
Format,
911
Message,
1012
OutputAsset,
@@ -15,16 +17,20 @@ import type { Nilable } from '@flex-development/tutils'
1517
import type { SerializedTimings } from 'rollup'
1618

1719
describe('unit-d:interfaces/Result', () => {
18-
it('should match [failure?: Error | null | undefined]', () => {
20+
it('should match [failure?: Failure | null | undefined]', () => {
1921
expectTypeOf<TestSubject>()
2022
.toHaveProperty('failure')
21-
.toEqualTypeOf<Nilable<Error>>()
23+
.toEqualTypeOf<Nilable<Failure>>()
2224
})
2325

2426
it('should match [format: Format]', () => {
2527
expectTypeOf<TestSubject>().toHaveProperty('format').toEqualTypeOf<Format>()
2628
})
2729

30+
it('should match [logger: Logger]', () => {
31+
expectTypeOf<TestSubject>().toHaveProperty('logger').toEqualTypeOf<Logger>()
32+
})
33+
2834
it('should match [messages: Message[]]', () => {
2935
expectTypeOf<TestSubject>()
3036
.toHaveProperty('messages')

src/interfaces/__tests__/task.spec-d.mts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
FooterFn,
1515
Format,
1616
Input,
17+
LogType,
1718
ResolveOptions,
1819
SanitizeFileNameFn,
1920
SourcemapFileNamesFn,
@@ -24,7 +25,7 @@ import type {
2425
import type { ModuleId } from '@flex-development/mlly'
2526
import type { Tsconfig } from '@flex-development/tsconfig-types'
2627
import type { Nilable } from '@flex-development/tutils'
27-
import type { HashCharacters, InputPluginOption, LogLevelOption } from 'rollup'
28+
import type { HashCharacters, InputPluginOption } from 'rollup'
2829

2930
describe('unit-d:interfaces/Task', () => {
3031
it('should match [assetFileNames?: AssetFileNamesFn | string | null | undefined]', () => {
@@ -57,10 +58,10 @@ describe('unit-d:interfaces/Task', () => {
5758
.toEqualTypeOf<Nilable<EntryFileNamesFn | string>>()
5859
})
5960

60-
it('should match [esbuild?: EsbuildOptions | null | undefined]', () => {
61+
it('should match [esbuild?: EsbuildOptions | false | null | undefined]', () => {
6162
expectTypeOf<TestSubject>()
6263
.toHaveProperty('esbuild')
63-
.toEqualTypeOf<Nilable<EsbuildOptions>>()
64+
.toEqualTypeOf<Nilable<EsbuildOptions | false>>()
6465
})
6566

6667
it('should match [experimental?: ExperimentalOptions | null | undefined]', () => {
@@ -111,10 +112,10 @@ describe('unit-d:interfaces/Task', () => {
111112
.toEqualTypeOf<Nilable<Input>>()
112113
})
113114

114-
it('should match [logLevel?: LogLevelOption | null | undefined]', () => {
115+
it('should match [logLevel?: LogType | "silent" | null | undefined]', () => {
115116
expectTypeOf<TestSubject>()
116117
.toHaveProperty('logLevel')
117-
.toEqualTypeOf<Nilable<LogLevelOption>>()
118+
.toEqualTypeOf<Nilable<LogType | 'silent'>>()
118119
})
119120

120121
it('should match [maxParallelFileOps?: number | null | undefined]', () => {

src/interfaces/failure.mts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @file Interfaces - Failure
3+
* @module mkbuild/interfaces/Failure
4+
*/
5+
6+
import type { Message } from '@flex-development/mkbuild'
7+
8+
/**
9+
* Build failure.
10+
*
11+
* @see {@linkcode Message}
12+
*/
13+
interface Failure extends Message {
14+
/**
15+
* Log level.
16+
*
17+
* @override
18+
*/
19+
level: 'error'
20+
}
21+
22+
export type { Failure as default }

src/interfaces/index.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type { default as EsbuildOptions } from '#interfaces/esbuild-options'
99
export type {
1010
default as ExperimentalOptions
1111
} from '#interfaces/experimental-options'
12+
export type { default as Failure } from '#interfaces/failure'
1213
export type { default as FileSystem } from '#interfaces/file-system'
1314
export type { default as Message } from '#interfaces/message'
1415
export type { default as MessageLocation } from '#interfaces/message-location'

src/interfaces/message.mts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
* @module mkbuild/interfaces/Message
44
*/
55

6-
import type { MessageLocation, RollupCode } from '@flex-development/mkbuild'
7-
import type * as rollup from 'rollup'
6+
import type {
7+
LogType,
8+
MessageLocation,
9+
RollupCode
10+
} from '@flex-development/mkbuild'
811

912
/**
1013
* Build message.
@@ -21,11 +24,11 @@ interface Message {
2124
cause?: unknown
2225

2326
/**
24-
* Message code.
27+
* Log code.
2528
*
2629
* @see {@linkcode RollupCode}
2730
*/
28-
code: RollupCode
31+
code?: RollupCode | null | undefined
2932

3033
/**
3134
* Module id of exporting file.
@@ -62,9 +65,14 @@ interface Message {
6265
/**
6366
* Log level of message.
6467
*
65-
* @see {@linkcode rollup.LogLevel}
68+
* @see {@linkcode LogType}
6669
*/
67-
level: rollup.LogLevel
70+
level: LogType
71+
72+
/**
73+
* Message text.
74+
*/
75+
message: string
6876

6977
/**
7078
* Message metadata.
@@ -101,11 +109,6 @@ interface Message {
101109
*/
102110
stack?: string | null | undefined
103111

104-
/**
105-
* Message text.
106-
*/
107-
text: string
108-
109112
/**
110113
* Help URL.
111114
*/

src/interfaces/result.mts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
* @module mkbuild/interfaces/Result
44
*/
55

6+
import type { Logger } from '@flex-development/log'
67
import type {
8+
Failure,
79
Format,
810
Message,
911
OutputAsset,
1012
OutputChunk,
1113
RunnableTask
1214
} from '@flex-development/mkbuild'
15+
import type { PackageJson } from '@flex-development/pkg-types'
1316
import type { SerializedTimings } from 'rollup'
1417

1518
/**
@@ -20,8 +23,10 @@ import type { SerializedTimings } from 'rollup'
2023
interface Result {
2124
/**
2225
* Build failure.
26+
*
27+
* @see {@linkcode Failure}
2328
*/
24-
failure?: Error | null | undefined
29+
failure?: Failure | null | undefined
2530

2631
/**
2732
* Output file format.
@@ -30,6 +35,13 @@ interface Result {
3035
*/
3136
format: Format
3237

38+
/**
39+
* Task logger.
40+
*
41+
* @see {@linkcode Logger}
42+
*/
43+
logger: Logger
44+
3345
/**
3446
* Build messages.
3547
*
@@ -52,6 +64,13 @@ interface Result {
5264
*/
5365
outputs: (OutputAsset | OutputChunk)[]
5466

67+
/**
68+
* Package manifest.
69+
*
70+
* @see {@linkcode PackageJson}
71+
*/
72+
pkg: PackageJson
73+
5574
/**
5675
* Absolute path to working directory.
5776
*/

0 commit comments

Comments
 (0)