Skip to content

Commit

Permalink
feat(core)!: default resolver cache (#2920)
Browse files Browse the repository at this point in the history
  • Loading branch information
idoros authored Oct 25, 2023
1 parent 9a0d08a commit 4fb2746
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 11 deletions.
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

0 comments on commit 4fb2746

Please sign in to comment.