borp 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +3 -0
- package/fixtures/monorepo/package-lock.json +35 -0
- package/fixtures/monorepo/package.json +15 -0
- package/fixtures/monorepo/package1/package.json +13 -0
- package/fixtures/monorepo/package1/src/lib/add.ts +4 -0
- package/fixtures/monorepo/package1/src/test/add.test.ts +7 -0
- package/fixtures/monorepo/package1/src/test/add2.test.ts +7 -0
- package/fixtures/monorepo/package1/tsconfig.json +10 -0
- package/fixtures/monorepo/package2/package.json +15 -0
- package/fixtures/monorepo/package2/src/lib/add.ts +4 -0
- package/fixtures/monorepo/package2/src/test/add.test.ts +7 -0
- package/fixtures/monorepo/package2/src/test/add2.test.ts +7 -0
- package/fixtures/monorepo/package2/tsconfig.json +11 -0
- package/fixtures/monorepo/tsconfig.base.json +24 -0
- package/fixtures/monorepo/tsconfig.json +7 -0
- package/lib/run.js +16 -7
- package/package.json +1 -1
- package/test/basic.test.js +25 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "project-build",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "project-build",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"workspaces": [
|
|
12
|
+
"package*"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"node_modules/package1": {
|
|
16
|
+
"resolved": "package1",
|
|
17
|
+
"link": true
|
|
18
|
+
},
|
|
19
|
+
"node_modules/package2": {
|
|
20
|
+
"resolved": "package2",
|
|
21
|
+
"link": true
|
|
22
|
+
},
|
|
23
|
+
"package1": {
|
|
24
|
+
"version": "1.0.0",
|
|
25
|
+
"license": "ISC"
|
|
26
|
+
},
|
|
27
|
+
"package2": {
|
|
28
|
+
"version": "1.0.0",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"package1": "file:../package1"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "project-build",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"workspaces": [
|
|
12
|
+
"package*"
|
|
13
|
+
],
|
|
14
|
+
"license": "ISC"
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "package1",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/src/lib/add.js",
|
|
6
|
+
"types": "dist/src/lib/add.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC"
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "package2",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"package1": "file:../package1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC"
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"sourceMap": true,
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"composite": true,
|
|
7
|
+
"module": "NodeNext",
|
|
8
|
+
"moduleResolution": "NodeNext",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"removeComments": true,
|
|
13
|
+
"newLine": "lf",
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"lib": [
|
|
20
|
+
"ESNext"
|
|
21
|
+
],
|
|
22
|
+
"incremental": true
|
|
23
|
+
}
|
|
24
|
+
}
|
package/lib/run.js
CHANGED
|
@@ -27,8 +27,10 @@ export default async function runWithTypeScript (config) {
|
|
|
27
27
|
|
|
28
28
|
let prefix = ''
|
|
29
29
|
let tscPath
|
|
30
|
+
const typescriptCliArgs = []
|
|
30
31
|
|
|
31
32
|
if (tsconfigPath && config.typescript !== false) {
|
|
33
|
+
const tsconfig = JSON.parse(await readFile(tsconfigPath))
|
|
32
34
|
const _require = createRequire(tsconfigPath)
|
|
33
35
|
const typescriptPathCWD = _require.resolve('typescript')
|
|
34
36
|
tscPath = join(typescriptPathCWD, '..', '..', 'bin', 'tsc')
|
|
@@ -38,19 +40,22 @@ export default async function runWithTypeScript (config) {
|
|
|
38
40
|
|
|
39
41
|
// Watch is handled aftterwards
|
|
40
42
|
if (!config.watch) {
|
|
43
|
+
if (Array.isArray(tsconfig.references) && tsconfig.references.length > 0) {
|
|
44
|
+
typescriptCliArgs.push('--build')
|
|
45
|
+
}
|
|
41
46
|
const start = Date.now()
|
|
42
|
-
await execa('node', [tscPath], { cwd: dirname(tsconfigPath) })
|
|
47
|
+
await execa('node', [tscPath, ...typescriptCliArgs], { cwd: dirname(tsconfigPath) })
|
|
43
48
|
process.stdout.write(`TypeScript compilation complete (${Date.now() - start}ms)\n`)
|
|
44
49
|
pushable.push({
|
|
45
50
|
type: 'test:diagnostic',
|
|
46
51
|
data: {
|
|
47
52
|
nesting: 0,
|
|
48
|
-
message: `TypeScript compilation complete (${Date.now() - start}ms)
|
|
53
|
+
message: `TypeScript compilation complete (${Date.now() - start}ms)`,
|
|
54
|
+
typescriptCliArgs
|
|
49
55
|
}
|
|
50
56
|
})
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
|
-
const tsconfig = JSON.parse(await readFile(tsconfigPath))
|
|
54
59
|
const outDir = tsconfig.compilerOptions.outDir
|
|
55
60
|
if (outDir) {
|
|
56
61
|
prefix = join(dirname(tsconfigPath), outDir)
|
|
@@ -83,17 +88,21 @@ export default async function runWithTypeScript (config) {
|
|
|
83
88
|
let p
|
|
84
89
|
|
|
85
90
|
if (config.watch) {
|
|
91
|
+
typescriptCliArgs.push('--watch')
|
|
86
92
|
p = deferred()
|
|
87
|
-
|
|
88
|
-
tscChild = execa('node', [tscPath,
|
|
93
|
+
let start = Date.now()
|
|
94
|
+
tscChild = execa('node', [tscPath, ...typescriptCliArgs], { cwd })
|
|
89
95
|
tscChild.stdout.setEncoding('utf8')
|
|
90
96
|
tscChild.stdout.on('data', (data) => {
|
|
91
|
-
if (data.includes('
|
|
97
|
+
if (data.includes('File change detected')) {
|
|
98
|
+
start = Date.now()
|
|
99
|
+
} else if (data.includes('Watching for file changes')) {
|
|
92
100
|
pushable.push({
|
|
93
101
|
type: 'test:diagnostic',
|
|
94
102
|
data: {
|
|
95
103
|
nesting: 0,
|
|
96
|
-
message: `TypeScript compilation complete (${Date.now() - start}ms)
|
|
104
|
+
message: `TypeScript compilation complete (${Date.now() - start}ms)`,
|
|
105
|
+
typescriptCliArgs
|
|
97
106
|
}
|
|
98
107
|
})
|
|
99
108
|
|
package/package.json
CHANGED
package/test/basic.test.js
CHANGED
|
@@ -2,6 +2,7 @@ import { test } from 'node:test'
|
|
|
2
2
|
import { tspl } from '@matteo.collina/tspl'
|
|
3
3
|
import runWithTypeScript from '../lib/run.js'
|
|
4
4
|
import { join } from 'desm'
|
|
5
|
+
import { execa } from 'execa'
|
|
5
6
|
|
|
6
7
|
test('ts-esm', async (t) => {
|
|
7
8
|
const { strictEqual, completed, match } = tspl(t, { plan: 4 })
|
|
@@ -141,7 +142,31 @@ test('src-to-dist', async (t) => {
|
|
|
141
142
|
|
|
142
143
|
await completed
|
|
143
144
|
})
|
|
145
|
+
test('monorepo', async (t) => {
|
|
146
|
+
const { strictEqual, completed, match, deepEqual } = tspl(t, { plan: 5 })
|
|
147
|
+
const config = {
|
|
148
|
+
files: [],
|
|
149
|
+
cwd: join(import.meta.url, '..', 'fixtures', 'monorepo/package2')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
await execa('npm', ['install'], { cwd: join(import.meta.url, '..', 'fixtures', 'monorepo') })
|
|
153
|
+
const stream = await runWithTypeScript(config)
|
|
154
|
+
|
|
155
|
+
const names = new Set(['package2-add', 'package2-add2'])
|
|
156
|
+
|
|
157
|
+
stream.once('data', (test) => {
|
|
158
|
+
strictEqual(test.type, 'test:diagnostic')
|
|
159
|
+
match(test.data.message, /TypeScript compilation complete \(\d+ms\)/)
|
|
160
|
+
deepEqual(test.data.typescriptCliArgs, ['--build'])
|
|
161
|
+
})
|
|
144
162
|
|
|
163
|
+
stream.on('test:pass', (test) => {
|
|
164
|
+
strictEqual(names.has(test.name), true)
|
|
165
|
+
names.delete(test.name)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
await completed
|
|
169
|
+
})
|
|
145
170
|
test('only-src', async (t) => {
|
|
146
171
|
const { strictEqual, completed, match } = tspl(t, { plan: 4 })
|
|
147
172
|
const config = {
|