The handling of the default export
is an important issue, but many bundlers and type bundlers handle the default export
differently, so ctix provides many ways to create a default export
.
You can change the generation style
of the entire project by setting the generation-style
option, or you can change the generation style
of only certain files by adding the @ctix-generation-style
inline comment at the top of the file.
Configuration for entire project.
{
"spinnerStream": "stdout",
"progressStream": "stdout",
"reasonerStream": "stderr",
"options": [
{
"mode": "bundle",
"project": "examples/type10/tsconfig.json",
"exportFilename": "index.ts",
"useSemicolon": true,
"useBanner": false,
"useTimestamp": false,
"quote": "'",
"directive": "",
"fileExt": "none",
"overwrite": true,
"backup": false,
"generationStyle": "auto", // check this option!
"include": ["**/*.ts"],
"exclude": [],
"skipEmptyDir": true,
"startFrom": "[...your path]/examples/type10",
"output": "examples/type10",
"removeBackup": false,
"forceYes": false
}
]
}
/** @ctix-generation-style default-alias-named-destructive */
// ComparisonCls
export class ComparisonCls {
private name: string = 'ComparisonCls';
}
Key | |
---|---|
auto | The generation-style option is selected automatically |
default-alias-named-star | default export using alias, named exports are star |
default-alias-named-destructive | default export using alias, each of the named exports becomes export by name |
default-non-alias-named-destructive | default export default , each of the named exports becomes export by name |
default-star-named-star | default , named exports becomes export by star |
default-star-named-destructive | default becomes export by star, each of the named exports becomes export by name |
// src/hero.ts
const hero = 'ironman';
export function greeting() {
return `hello! ${hero}`;
}
export default hero;
export * from 'src/hero';
// src/hero.ts
const hero = 'ironman';
export function greeting() {
return `hello! ${hero}`;
}
export function flying() {
return `${hero} flying!`;
}
export default hero;
export * from 'src/hero';
export { greeting, flying } from 'src/hero';
// src/hero.ts
const hero = 'ironman';
export function greeting() {
return `hello! ${hero}`;
}
export function flying() {
return `${hero} flying!`;
}
export default hero;
export { default as hero } from 'src/hero';
export * from 'src/hero';
// src/hero.ts
const hero = 'ironman';
export function greeting() {
return `hello! ${hero}`;
}
export function flying() {
return `${hero} flying!`;
}
export default hero;
export { default as hero, greeting, flying } from 'src/hero';
// src/hero.ts
const hero = 'ironman';
export function greeting() {
return `hello! ${hero}`;
}
export function flying() {
return `${hero} flying!`;
}
export default hero;
export { default, greeting, flying } from 'src/hero';