Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli)!: make fs required in resolveConfig function #2913

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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