Skip to content

Commit

Permalink
chore: rename to createWebpackResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
barak007 committed Oct 1, 2023
1 parent 48445e7 commit 8134ecf
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions packages/cli/test/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,12 @@ describe('Stylable Cli', function () {
'package.json': `{"name": "test", "version": "0.0.0"}`,
'stylable.config.js': `
const { resolve } = require('node:path');
const { createLegacyResolver } = require('@stylable/webpack-plugin');
const { createWebpackResolver } = require('@stylable/webpack-plugin');
module.exports = {
defaultConfig(fs) {
return {
resolveModule: createLegacyResolver(fs, {
resolveModule: createWebpackResolver(fs, {
alias: {
'@colors': resolve(__dirname, './colors')
}
Expand Down Expand Up @@ -618,12 +618,12 @@ describe('Stylable Cli', function () {
'stylable.config.js': `
const { join } = require('path');
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
const { createLegacyResolver } = require('@stylable/webpack-plugin');
const { createWebpackResolver } = require('@stylable/webpack-plugin');
module.exports = {
defaultConfig(fs) {
return {
resolveModule: createLegacyResolver(fs, {
resolveModule: createWebpackResolver(fs, {
plugins: [new TsconfigPathsPlugin({ configFile: join(${JSON.stringify(
tempDir.path
)},'tsconfig.json') })],
Expand Down
4 changes: 2 additions & 2 deletions packages/experimental-loader/src/stylable-transform-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Warning, CssSyntaxError } from './warning';
import { getStylable } from './cached-stylable-factory';
import { createRuntimeTargetCode } from './create-runtime-target-code';
import { addBuildInfo } from './add-build-info';
import { createLegacyResolver } from '@stylable/webpack-plugin';
import { createWebpackResolver } from '@stylable/webpack-plugin';
import type { LoaderDefinition, LoaderContext } from 'webpack';

// TODO: maybe adopt the code
Expand Down Expand Up @@ -65,7 +65,7 @@ const stylableLoader: LoaderDefinition = function (content) {
};
const mode = this._compiler!.options.mode === 'development' ? 'development' : 'production';

const resolveModule = createLegacyResolver(
const resolveModule = createWebpackResolver(
this.fs as any,
this._compiler!.options.resolve as any
);
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-extensions/src/stylable-manifest-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Stylable, StylableMeta } from '@stylable/core';
import { createLegacyResolver } from '@stylable/webpack-plugin';
import { createWebpackResolver } from '@stylable/webpack-plugin';
import { STSymbol } from '@stylable/core/dist/index-internal';
import { resolveNamespace } from '@stylable/node';
import { createMetadataForStylesheet } from './create-metadata-stylesheet';
Expand Down Expand Up @@ -56,7 +56,7 @@ export class StylableManifestPlugin {
this.options = Object.assign({}, defaultOptions, options);
}
public apply(compiler: Compiler) {
const resolveModule = createLegacyResolver(compiler.inputFileSystem as any, {
const resolveModule = createWebpackResolver(compiler.inputFileSystem as any, {
...compiler.options.resolve as any,
extensions: [],
});
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-extensions/src/stylable-metadata-loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Stylable, processNamespace } from '@stylable/core';
import { createStylableResolverCacheMap, createLegacyResolver } from '@stylable/webpack-plugin';
import { createStylableResolverCacheMap, createWebpackResolver } from '@stylable/webpack-plugin';
import findConfig from 'find-config';
import type { LoaderDefinition, LoaderContext } from 'webpack';
import { createMetadataForStylesheet } from './create-metadata-stylesheet';
Expand Down Expand Up @@ -49,7 +49,7 @@ function createStylable(
if (!loader._compiler) {
throw new Error('Stylable metadata loader requires a compiler instance');
}
const resolveModule = createLegacyResolver(loader.fs as any, {
const resolveModule = createWebpackResolver(loader.fs as any, {
...(loader._compiler.options.resolve as any),
extensions: [],
});
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ export {
WebpackCreateHash,
WebpackOutputOptions,
} from './types';
export { createLegacyResolver } from './legacy-module-resolver';
export { createWebpackResolver } from './legacy-module-resolver';
2 changes: 1 addition & 1 deletion packages/webpack-plugin/src/legacy-module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function bundleSafeRequireExtensions(): string[] {

const resolverContext = {};

export function createLegacyResolver(fileSystem: ResolveOptions['fileSystem'], resolveOptions: Partial<ResolveOptions>) {
export function createWebpackResolver(fileSystem: ResolveOptions['fileSystem'], resolveOptions: Partial<ResolveOptions>) {
const extensions =
resolveOptions.extensions && resolveOptions.extensions.length
? resolveOptions.extensions
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import type {
import { parse } from 'postcss';
import { getWebpackEntities, StylableWebpackEntities } from './webpack-entities';
import { resolveConfig as resolveStcConfig, STCBuilder } from '@stylable/cli';
import { createLegacyResolver } from './legacy-module-resolver';
import { createWebpackResolver } from './legacy-module-resolver';

type OptimizeOptions = OptimizeConfig & {
minify?: boolean;
Expand Down Expand Up @@ -370,7 +370,7 @@ export class StylableWebpackPlugin {
const stylableConfig = this.getStylableConfig(compiler)?.config;

validateDefaultConfig(stylableConfig?.defaultConfig);
const resolveModule = createLegacyResolver(topLevelFs, {
const resolveModule = createWebpackResolver(topLevelFs, {
...resolverOptions,
extensions: [], // use Stylable's default extensions
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { StylableWebpackPlugin, createLegacyResolver } = require('@stylable/webpack-plugin');
const { StylableWebpackPlugin, createWebpackResolver } = require('@stylable/webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

/** @type {import('webpack').Configuration} */
Expand All @@ -12,7 +12,7 @@ module.exports = {
stylableConfig(config, compiler) {
// set custom resolve for test

const resolve = createLegacyResolver(compiler.inputFileSystem, {});
const resolve = createWebpackResolver(compiler.inputFileSystem, {});
config.resolveModule = (path, request) => {
if (request === './resolve-me') {
return resolve(path, './custom-resolved.css');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//@ts-check
const { join } = require('path');
const { createLegacyResolver } = require('@stylable/webpack-plugin');
const { createWebpackResolver } = require('@stylable/webpack-plugin');

module.exports = {
defaultConfig(fs) {
return {
resolveModule: createLegacyResolver(fs, {
resolveModule: createWebpackResolver(fs, {
alias: {
'wp-alias': join(__dirname, 'src/wrong'),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { StylableWebpackPlugin } = require('@stylable/webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { join } = require('path');
const { createLegacyResolver } = require('@stylable/webpack-plugin');
const { createWebpackResolver } = require('@stylable/webpack-plugin');

/** @type {import('webpack').Configuration} */
module.exports = {
Expand All @@ -12,7 +12,7 @@ module.exports = {
new StylableWebpackPlugin({
stylableConfig: (config) => ({
...config,
resolveModule: createLegacyResolver(config.fileSystem, {
resolveModule: createWebpackResolver(config.fileSystem, {
alias: {
'wp-alias': join(__dirname, 'src/webpack-alias'),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//@ts-check
const { join } = require('path');
const { createLegacyResolver } = require('@stylable/webpack-plugin');
const { createWebpackResolver } = require('@stylable/webpack-plugin');

module.exports = {
defaultConfig(fs) {
return {
resolveModule: createLegacyResolver(fs, {
resolveModule: createWebpackResolver(fs, {
alias: {
'wp-alias': join(__dirname, 'src/wrong'),
},
Expand All @@ -18,7 +18,7 @@ module.exports = {
stylableConfig(defaultStylableConfig) {
return {
...defaultStylableConfig,
resolveModule: createLegacyResolver(fs, {
resolveModule: createWebpackResolver(fs, {
alias: {
'wp-alias': join(__dirname, 'src/webpack-alias'),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//@ts-check
const { join } = require('path');
const { createLegacyResolver } = require('@stylable/webpack-plugin');
const { createWebpackResolver } = require('@stylable/webpack-plugin');
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');

module.exports = {
defaultConfig(fs) {
return {
resolveModule: createLegacyResolver(fs, {
resolveModule: createWebpackResolver(fs, {
alias: {
'wp-alias': join(__dirname, 'src/webpack-alias'),
},
Expand Down

0 comments on commit 8134ecf

Please sign in to comment.