Skip to content

Commit be1018a

Browse files
fix: use tsc for bundling modules
1 parent 095ca7d commit be1018a

File tree

2 files changed

+26
-58
lines changed

2 files changed

+26
-58
lines changed

fuse.ts

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { resolve } from 'path'
44
import { argv } from 'yargs'
55
import shabang from './tools/scripts/fuse-shebang'
66
import { SparkyFile } from 'fuse-box/sparky/SparkyFile'
7-
import { unlinkSync } from 'fs'
7+
import { spawn } from 'child_process'
8+
// import { unlinkSync } from 'fs'
89

910
const appName = 'fng'
1011
const outputDir = '.build'
@@ -48,7 +49,7 @@ task('cp.jest', () => {
4849
return src('jest/**', { base: 'src/templates/unit-tests' }).dest('.build/')
4950
})
5051

51-
task('bundle', ['cp.jest', 'ng.util', 'ng.svg'], () => {
52+
task('bundle', ['cp.jest', 'ng.modules'], () => {
5253
bundle.instructions('> [src/index.ts]')
5354
!isProdBuild &&
5455
bundle.watch(`src/**`).completed(fp => shabang(fp.bundle, absOutputPath))
@@ -59,61 +60,12 @@ task('bundle', ['cp.jest', 'ng.util', 'ng.svg'], () => {
5960
})
6061
})
6162

62-
task('ng.svg', () => {
63-
const config = FuseBox.init({
64-
homeDir,
65-
target: 'universal@es5',
66-
output: `${outputDir}/modules/svg/$name.js`,
67-
globals: {
68-
default: '*'
69-
},
70-
package: {
71-
name: 'default',
72-
main: outputPath
73-
}
63+
task('ng.modules', () => {
64+
return new Promise((res, rej) => {
65+
const tsc = spawn(resolve('node_modules/.bin/tsc'), [
66+
'--p',
67+
resolve('src/modules')
68+
])
69+
tsc.on('close', res)
7470
})
75-
src('test.ts', { base: 'src/modules/svg' })
76-
.dest('.build/modules/svg')
77-
.exec()
78-
src('src/modules/svg/index.ts')
79-
.file('*', (file: SparkyFile) => file.rename('index.d.ts'))
80-
.dest('.build/modules/svg/$name')
81-
.exec()
82-
83-
config.bundle('index').instructions('> [src/modules/svg/test.ts]')
84-
config.run()
85-
})
86-
87-
task('ng.util', () => {
88-
const config = FuseBox.init({
89-
homeDir,
90-
target: 'universal@es5',
91-
output: `${outputDir}/modules/util/$name.js`,
92-
globals: {
93-
default: '*'
94-
},
95-
package: {
96-
name: 'default',
97-
main: outputPath
98-
}
99-
})
100-
src('**/*.ts', { base: 'src/modules/util' })
101-
.dest('.build/modules/util')
102-
.exec()
103-
.then(() => {
104-
return src('.build/modules/util/index.ts')
105-
.file('*', (file: SparkyFile) => file.rename('index.d.ts'))
106-
.dest('.build/modules/util/$name')
107-
.exec()
108-
.then(() => {
109-
unlinkSync('.build/modules/util/index.ts')
110-
})
111-
})
112-
113-
config
114-
.bundle('index')
115-
.instructions(
116-
'> [src/modules/util/tokens.ts] + [src/modules/util/window.service.ts]'
117-
)
118-
config.run()
11971
})

src/modules/tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es2015",
5+
"importHelpers": true,
6+
"emitDecoratorMetadata": true,
7+
"experimentalDecorators": true,
8+
"noUnusedLocals": true,
9+
"noImplicitAny": true,
10+
"strictNullChecks": true,
11+
"lib": ["es6", "dom"],
12+
"typeRoots": ["tools/manual-typings", "node_modules/@types"],
13+
"outDir": "../../.build/modules",
14+
"declaration": true
15+
}
16+
}

0 commit comments

Comments
 (0)