Merge branch 'tech/prebundle-wip' into tech/bundling-router

This commit is contained in:
Norbert de Langen 2022-01-28 15:01:44 +01:00
commit 8be94cfe6a
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
3 changed files with 36 additions and 12 deletions

View File

@ -129,20 +129,30 @@ async function build(options: Options) {
async function dts({ input, externals, cwd, ...options }: Options) {
if (options.watch) {
try {
const [out] = await generateDtsBundle([
const [out] = await generateDtsBundle(
[
{
filePath: input,
output: { inlineDeclareGlobals: false, sortNodes: true, noBanner: true },
},
]);
],
{ followSymlinks: false }
);
await fs.outputFile('dist/ts3.9/index.d.ts', out);
} catch (e) {
console.log(e.message);
}
} else {
const [out] = await generateDtsBundle([
{ filePath: input, output: { inlineDeclareGlobals: false, sortNodes: true, noBanner: true } },
]);
const [out] = await generateDtsBundle(
[
{
filePath: input,
output: { inlineDeclareGlobals: false, sortNodes: true, noBanner: true },
},
],
{ followSymlinks: false }
);
const bundledDTSfile = path.join(cwd, 'dist/ts-tmp/index.d.ts');
const localizedDTSout = path.join(cwd, 'dist/ts3.9');
@ -160,11 +170,19 @@ async function dts({ input, externals, cwd, ...options }: Options) {
}
}
async function removeDist() {
await fs.remove('dist');
}
export async function run({ cwd, flags }: { cwd: string; flags: string[] }) {
const { packageJson: pkg } = await readPkgUp({ cwd });
const message = gray(`Built: ${bold(`${pkg.name}@${pkg.version}`)}`);
console.time(message);
if (flags.includes('--reset')) {
await removeDist();
}
const input = path.join(cwd, pkg.bundlerEntrypoint);
const externals = Object.keys({ ...pkg.dependencies, ...pkg.peerDependencies });

View File

@ -278,6 +278,10 @@ export const run = async (entrySourceFiles: string[], outputPath: string, option
if (!x) {
return;
}
if (replaceRemapping.has(v.resolvedFileName)) {
return;
}
actOnSourceFile(sourceFiles.find((f) => f.fileName === v.resolvedFileName));
});
}

View File

@ -7,18 +7,20 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"jsx": "react",
"module": "commonjs",
"moduleResolution": "Node",
"module": "CommonJS",
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"target": "es5",
"target": "ES2015",
"types": [
"jest"
],
"lib": [
"es2019",
"dom"
"dom",
"ESNext"
]
},
"exclude": [