Skip to content

Commit 9f166b9

Browse files
committed
wip
1 parent bc8bd3a commit 9f166b9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/signals/signals-runtime/bundle-dts.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ function appendFileContents(targetFilePath, sourceFilePath, divider = '\n') {
1919
})
2020
}
2121

22-
function removeExport(filePath) {
22+
function removeImportExport(filePath) {
2323
const data = fs.readFileSync(filePath, { encoding: 'utf-8' })
2424
// remove export declarations and non-interface/type exports
2525
const processedContent = data
2626
.split('\n')
2727
.filter((line) => {
28+
const l = line.trim()
2829
// Remove export declarations
29-
if (line.trim().startsWith('export ')) {
30+
if (l.startsWith('export ')) {
3031
// Keep only interface and type exports
31-
return line.includes('interface') || line.includes('type')
32+
return l.includes('interface') || l.includes('type')
33+
}
34+
if (l.startsWith('import')) {
35+
return false
3236
}
3337
return true
3438
})
@@ -62,16 +66,15 @@ const main = () => {
6266
const command = `yarn dts-bundle-generator -o ${outFile} src/web-exports.ts --no-check`
6367
execSync(command, { stdio: 'inherit' })
6468
const outFileAbs = path.join(__dirname, outFile)
65-
removeExport(outFileAbs)
6669

67-
// Prepend ignore artifactions
6870
prependGenerated(outFileAbs)
6971

7072
// Append the contents of web-exports-globals.ts
7173
const globalsFilePath = path.join(__dirname, 'src/web-exports-globals.ts')
7274
appendFileContents(outFileAbs, globalsFilePath)
7375
// remove any comments that use // like ts-ignore, ts-nocheck etc (/* */ is OK)
7476
filterLines(outFileAbs, (line) => !line.startsWith('//'))
77+
removeImportExport(outFileAbs)
7578
}
7679

7780
main()

packages/signals/signals-runtime/src/web-exports-globals.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// @ts-nocheck
1+
// all import directives will be removed in the final build
2+
import { SignalsRuntimeAPI } from './types/web/signals'
3+
24
// This will be appended to the generated code - dts-bundle-generator will not write declare const for whatever reason.
35
declare const signals: SignalsRuntimeAPI
46
declare const SignalType: {

0 commit comments

Comments
 (0)