Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public createStylable(compiler: webpack.Compiler) {
const stylable = new Stylable(
compiler.context,
(compiler.inputFileSystem as any).fileSystem || (compiler.inputFileSystem as any),
this.options.requireModule,
'__',
meta => {
if (this.options.unsafeBuildNamespace) {
try {
meta.namespace = require(meta.source + '.js').namespace;
} catch {
/* */
}
}
// meta.namespace = getNamespaceFromBuiltStylsheet()
// TODO: move to stylable as param.
if (this.options.optimize.shortNamespaces) {
import { StylableLanguageService } from '../src/lib/service';
export const CASES_PATH = fs.join(
fs.dirname(fs.findClosestFileSync(__dirname, 'package.json')!),
'test',
'fixtures',
'server-cases'
);
function requireModule(request: string) {
return require(require.resolve(request, { paths: [CASES_PATH] }));
}
export const stylableLSP = new StylableLanguageService({
fs,
stylable: new Stylable(CASES_PATH, fs as any, requireModule)
});
export function createStylableInstance(config: Config) {
config.trimWS = true;
const { fs, requireModule } = createMinimalFS(config);
const stylable = new Stylable(
'/',
fs as any,
requireModule,
'__',
(meta, path) => {
meta.namespace = config.files[path].namespace || meta.namespace;
return meta;
},
undefined,
undefined,
config.resolve
);
return stylable;
}