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

feat(core)!: default resolver cache #2920

Merged
merged 2 commits into from
Oct 25, 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/core/src/stylable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class Stylable {
this.resolveNamespace = config.resolveNamespace;
this.moduleResolver = this.initModuleResolver(config);
this.cssParser = config.cssParser || cssParse;
this.resolverCache = config.resolverCache; // ToDo: v5 default to `new Map()`
this.resolverCache = config.resolverCache || new Map();
this.fileProcessorCache = config.fileProcessorCache;
this.fileProcessor = createStylableFileProcessor({
fileSystem: this.fileSystem,
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/stylable-resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ describe('stylable-resolver', () => {
{},
{
stylableConfig: {
resolverCache: new Map(),
resolveModule: () => {
resolverHits++;
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('Transformer', () => {
{
stylableConfig: {
resolveModule: onResolve,
resolverCache: new Map(), // ToDo: v5 this should be default : remove
},
}
);
Expand Down
1 change: 0 additions & 1 deletion packages/esbuild/src/stylable-esbuild-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export const stylablePlugin = (initialPluginOptions: ESBuildOptions = {}): Plugi
projectRoot,
fileSystem: fs,
optimizer: new StylableOptimizer(),
resolverCache: new Map(),
requireModule,
resolveNamespace:
configFromFile?.config?.defaultConfig?.resolveNamespace ?? resolveNamespaceNode,
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin-stylable/src/stylable-es-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default createRule({
projectRoot: process.cwd(),
resolveModule: moduleResolver,
requireModule: require,
resolverCache: new Map(),
cssParser: safeParse,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getStylable(compiler: Compiler, initialConfig: StylableConfig):
return require(id);
};

stylable = new Stylable({ ...initialConfig, requireModule, resolverCache: new Map() });
stylable = new Stylable({ ...initialConfig, requireModule });
compiler.hooks.done.tap('StylableLoader stylable.initCache', () => {
stylable!.initCache();
for (const id of requireModuleCache) {
Expand Down
1 change: 0 additions & 1 deletion packages/node/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ async function initiateModuleFactory() {
...(defaultConfig?.config || {}),
projectRoot: '/',
fileSystem: fs,
resolverCache: new Map(),
},
{
moduleType: 'esm',
Expand Down
1 change: 0 additions & 1 deletion packages/node/src/require-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function attachHook({
fileSystem: fs,
requireModule: require,
resolveNamespace,
resolverCache: new Map(),
...options,
},
{ runtimePath }
Expand Down
1 change: 0 additions & 1 deletion packages/rollup-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export function stylableRollupPlugin({
const stConfig = stylableConfig({
fileSystem: fs,
optimizer: new StylableOptimizer(),
resolverCache: new Map(),
requireModule,
mode: mode || getDefaultMode(),
projectRoot: projectRoot || process.cwd(),
Expand Down
3 changes: 1 addition & 2 deletions packages/webpack-extensions/src/stylable-manifest-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class StylableManifestPlugin {
}
public apply(compiler: Compiler) {
const resolveModule = createWebpackResolver(compiler.inputFileSystem as any, {
...compiler.options.resolve as any,
...(compiler.options.resolve as any),
extensions: [],
});
const stylable = new Stylable({
Expand All @@ -68,7 +68,6 @@ export class StylableManifestPlugin {
},
mode: compiler.options.mode === 'development' ? 'development' : 'production',
resolveModule,
resolverCache: new Map(),
resolveNamespace: this.options.resolveNamespace,
});

Expand Down