Skip to content

Commit

Permalink
ci: fix post build out of memory issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Jul 1, 2024
1 parent 1cebce9 commit 1e3b446
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"postbuild": "pnpm run postbuild:gen",
"postbuild:gen": "pnpm run gen:dts && pnpm run gen:interfaces",
"postbuild:dist:local": "node ./scripts/copy-dist-local.js",
"build": "pnpm run prebuild && pnpm run build:lib",
"build": "pnpm run prebuild && pnpm run build:lib && pnpm run postbuild",
"build:dist:local": "pnpm run build && pnpm run postbuild:dist:local",
"build:docker": "vite build --mode docker",
"build:local": "vite build --mode local",
Expand Down
68 changes: 33 additions & 35 deletions scripts/gen-dts.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,45 +65,43 @@ async function genVueTypes(
.filter(exclude)
.filter(include);

await Promise.all(
filePaths.map(async file => {
try {
if (file.endsWith('.vue')) {
// .vue file
const content = await fs.promises.readFile(file, 'utf-8');
const sfc = vueCompiler.parse(content);
const { script, scriptSetup } = sfc.descriptor;
if (script || scriptSetup) {
let content = '';
let isTS = false;
if (script && script.content) {
content += script.content;
if (script.lang === 'ts') isTS = true;
}
if (scriptSetup) {
const compiled = vueCompiler.compileScript(sfc.descriptor, {
id: 'xxx',
});
content += compiled.content;
if (scriptSetup.lang === 'ts') isTS = true;
}
const sourceFile = project.createSourceFile(
path.relative(process.cwd(), file) + (isTS ? '.ts' : '.js'),
content
);
sourceFiles.push(sourceFile);
filePaths.forEach(file => {
try {
if (file.endsWith('.vue')) {
// .vue file
const content = fs.readFileSync(file, 'utf-8');
const sfc = vueCompiler.parse(content);
const { script, scriptSetup } = sfc.descriptor;
if (script || scriptSetup) {
let content = '';
let isTS = false;
if (script && script.content) {
content += script.content;
if (script.lang === 'ts') isTS = true;
}
if (scriptSetup) {
const compiled = vueCompiler.compileScript(sfc.descriptor, {
id: 'xxx',
});
content += compiled.content;
if (scriptSetup.lang === 'ts') isTS = true;
}
} else if (file.endsWith('.ts')) {
// .ts file
const sourceFile = project.addSourceFileAtPath(file);
const sourceFile = project.createSourceFile(
path.relative(process.cwd(), file) + (isTS ? '.ts' : '.js'),
content
);
sourceFiles.push(sourceFile);
}
} catch (e) {
console.error(e);
throw e;
} else if (file.endsWith('.ts')) {
// .ts file
const sourceFile = project.addSourceFileAtPath(file);
sourceFiles.push(sourceFile);
}
})
);
} catch (e) {
console.error(e);
throw e;
}
});
log(
`Found valid source files: ${sourceFiles.length}/${filePaths.length}`,
'success'
Expand Down

0 comments on commit 1e3b446

Please sign in to comment.