Skip to content

Commit

Permalink
refactor(cli)!: make fs required in resolveConfig function (#2913)
Browse files Browse the repository at this point in the history
  • Loading branch information
idoros committed Oct 2, 2023
1 parent ee072f8 commit 86c105b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/build-stylable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function buildStylable(
watchOptions = {},
}: BuildStylableContext = {}
) {
const { config } = resolveConfig(rootDir, configFilePath, fs) || {};
const { config } = resolveConfig(rootDir, fs, configFilePath) || {};
validateDefaultConfig(config?.defaultConfig);

const projects = await projectsConfig(rootDir, overrideBuildOptions, defaultOptions, config);
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/config/projects-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export async function projectsConfig(
return projects;
}

// todo: make fs not optional next major version
export function resolveConfig(context: string, request?: string, fs?: IFileSystem) {
export function resolveConfig(context: string, fs: IFileSystem, request?: string) {
return request ? requireConfigFile(request, context, fs) : resolveConfigFile(context, fs);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/esbuild/src/stylable-esbuild-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export const stylablePlugin = (initialPluginOptions: ESBuildOptions = {}): Plugi
const projectRoot = build.initialOptions.absWorkingDir || process.cwd();
const configFromFile = resolveConfig(
projectRoot,
typeof configFile === 'string' ? configFile : undefined,
fs
fs,
typeof configFile === 'string' ? configFile : undefined
);
const stConfig = stylableConfig(
{
Expand Down
4 changes: 2 additions & 2 deletions packages/rollup-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export function stylableRollupPlugin({
});
configFromFile = resolveStcConfig(
stConfig.projectRoot,
typeof stcConfig === 'string' ? stcConfig : undefined,
fs
fs,
typeof stcConfig === 'string' ? stcConfig : undefined
);

stylable = new Stylable({
Expand Down
9 changes: 6 additions & 3 deletions packages/webpack-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ export class StylableWebpackPlugin {
private getStylableConfig(compiler: Compiler) {
const configuration = resolveStcConfig(
compiler.context,
typeof this.options.stcConfig === 'string' ? this.options.stcConfig : undefined,
getTopLevelInputFilesystem(compiler)
getTopLevelInputFilesystem(compiler),
typeof this.options.stcConfig === 'string' ? this.options.stcConfig : undefined
);

return configuration;
Expand Down Expand Up @@ -359,7 +359,10 @@ export class StylableWebpackPlugin {
return;
}

const resolverOptions: Omit<ResolveOptionsWebpackOptions, 'fileSystem' | 'resolver' | 'plugins'> = {
const resolverOptions: Omit<
ResolveOptionsWebpackOptions,
'fileSystem' | 'resolver' | 'plugins'
> = {
...compiler.options.resolve,
aliasFields:
compiler.options.resolve.byDependency?.esm?.aliasFields ||
Expand Down

0 comments on commit 86c105b

Please sign in to comment.