Skip to content

Commit

Permalink
add a compilePackages config option
Browse files Browse the repository at this point in the history
  • Loading branch information
mrm007 committed Oct 13, 2022
1 parent c893cf5 commit 5b1d96c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export const build = async (inlineConfig?: PartialConfig) => {
vanillaExtractPlugin({ identifiers: 'short' }),
addPageRoots(config),
],
logLevel: 'silent',
logLevel: 'warn',
ssr: {
external: ['serialize-javascript', 'used-styles', ...builtinModules],
noExternal: ['braid-design-system'],
external: [...builtinModules, 'serialize-javascript', 'used-styles'],
noExternal: config.compilePackages,
},
};

Expand Down
19 changes: 15 additions & 4 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,22 @@ export interface Config {
pageRoots: string[];

/**
* Path to the App shell component
* Path to the App shell component.
* @default 'src/App.tsx'
*/
appShell: `${string}.tsx`;

/**
* Override TypeScript `compilerOptions` for when generating `.d.ts` files
* @default '{ incremental: false, noEmitOnError: false }'
* Override TypeScript `compilerOptions` when generating `.d.ts` files.
* @default { incremental: false, noEmitOnError: false }
*/
dtsOptions: Record<string, unknown>;

/**
* An array of `node_modules` to be compiled as if they were part of your source code.
* @default ['braid-design-system']
*/
compilePackages: Array<string>;
}

export interface EnhancedConfig extends Config {
Expand All @@ -69,6 +75,7 @@ export const defaultConfig: Config = {
incremental: false,
noEmitOnError: false,
},
compilePackages: ['braid-design-system'],
};

const determineAppShell = (
Expand All @@ -90,13 +97,17 @@ const determineAppShell = (
};

export const getConfig = (inlineConfig?: PartialConfig): EnhancedConfig => {
const config = {
const config: Config = {
...defaultConfig,
...inlineConfig,
dtsOptions: {
...defaultConfig.dtsOptions,
...inlineConfig?.dtsOptions,
},
compilePackages: [
...defaultConfig.compilePackages,
...(inlineConfig?.compilePackages ?? []),
],
};

const resolveFromRoot = (filePath: string) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export const start = async (
},
ssr: {
external: [
...builtinModules,
'@crackle/router',
'serialize-javascript',
'used-styles',
...builtinModules,
],
noExternal: ['braid-design-system'],
noExternal: config.compilePackages,
},
});
// use vite's connect instance as middleware
Expand Down

0 comments on commit 5b1d96c

Please sign in to comment.