mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
Merge branch 'tech/prebundle-wip' into tech/bundling-router
This commit is contained in:
commit
8be94cfe6a
@ -129,20 +129,30 @@ async function build(options: Options) {
|
|||||||
async function dts({ input, externals, cwd, ...options }: Options) {
|
async function dts({ input, externals, cwd, ...options }: Options) {
|
||||||
if (options.watch) {
|
if (options.watch) {
|
||||||
try {
|
try {
|
||||||
const [out] = await generateDtsBundle([
|
const [out] = await generateDtsBundle(
|
||||||
|
[
|
||||||
{
|
{
|
||||||
filePath: input,
|
filePath: input,
|
||||||
output: { inlineDeclareGlobals: false, sortNodes: true, noBanner: true },
|
output: { inlineDeclareGlobals: false, sortNodes: true, noBanner: true },
|
||||||
},
|
},
|
||||||
]);
|
],
|
||||||
|
{ followSymlinks: false }
|
||||||
|
);
|
||||||
|
|
||||||
await fs.outputFile('dist/ts3.9/index.d.ts', out);
|
await fs.outputFile('dist/ts3.9/index.d.ts', out);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const [out] = await generateDtsBundle([
|
const [out] = await generateDtsBundle(
|
||||||
{ filePath: input, output: { inlineDeclareGlobals: false, sortNodes: true, noBanner: true } },
|
[
|
||||||
]);
|
{
|
||||||
|
filePath: input,
|
||||||
|
output: { inlineDeclareGlobals: false, sortNodes: true, noBanner: true },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{ followSymlinks: false }
|
||||||
|
);
|
||||||
|
|
||||||
const bundledDTSfile = path.join(cwd, 'dist/ts-tmp/index.d.ts');
|
const bundledDTSfile = path.join(cwd, 'dist/ts-tmp/index.d.ts');
|
||||||
const localizedDTSout = path.join(cwd, 'dist/ts3.9');
|
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[] }) {
|
export async function run({ cwd, flags }: { cwd: string; flags: string[] }) {
|
||||||
const { packageJson: pkg } = await readPkgUp({ cwd });
|
const { packageJson: pkg } = await readPkgUp({ cwd });
|
||||||
const message = gray(`Built: ${bold(`${pkg.name}@${pkg.version}`)}`);
|
const message = gray(`Built: ${bold(`${pkg.name}@${pkg.version}`)}`);
|
||||||
console.time(message);
|
console.time(message);
|
||||||
|
|
||||||
|
if (flags.includes('--reset')) {
|
||||||
|
await removeDist();
|
||||||
|
}
|
||||||
|
|
||||||
const input = path.join(cwd, pkg.bundlerEntrypoint);
|
const input = path.join(cwd, pkg.bundlerEntrypoint);
|
||||||
const externals = Object.keys({ ...pkg.dependencies, ...pkg.peerDependencies });
|
const externals = Object.keys({ ...pkg.dependencies, ...pkg.peerDependencies });
|
||||||
|
|
||||||
|
@ -278,6 +278,10 @@ export const run = async (entrySourceFiles: string[], outputPath: string, option
|
|||||||
if (!x) {
|
if (!x) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (replaceRemapping.has(v.resolvedFileName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
actOnSourceFile(sourceFiles.find((f) => f.fileName === v.resolvedFileName));
|
actOnSourceFile(sourceFiles.find((f) => f.fileName === v.resolvedFileName));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,18 +7,20 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"module": "commonjs",
|
"moduleResolution": "Node",
|
||||||
|
"module": "CommonJS",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"target": "es5",
|
"target": "ES2015",
|
||||||
"types": [
|
"types": [
|
||||||
"jest"
|
"jest"
|
||||||
],
|
],
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2019",
|
"es2019",
|
||||||
"dom"
|
"dom",
|
||||||
|
"ESNext"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user