How to use the @stylable/core.Stylable.create function in @stylable/core

To help you get started, we’ve selected a few @stylable/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wix / stylable / packages / cli / src / cli.ts View on Github external
minify,
    manifestFilepath,
    manifest,
    require: requires
} = argv;

log('[Arguments]', argv);

// execute all require hooks before running the CLI build
for (const request of requires) {
    if (request) {
        require(request);
    }
}

const stylable = Stylable.create({
    fileSystem: fs,
    requireModule: require,
    projectRoot: rootDir,
    resolveNamespace: require(namespaceResolver).resolveNamespace
});

build({
    extension: ext,
    fs,
    stylable,
    outDir,
    srcDir,
    rootDir,
    log,
    diagnostics,
    indexFile,
github wix / stylable / packages / module-utils / src / module-factory.ts View on Github external
export function stylableModuleFactory(
    stylableOptions: StylableConfig,
    {
        runtimePath = '@stylable/runtime',
        runtimeStylesheetId = 'module',
        injectCSS = true,
        renderableOnly = false,
        legacyRuntime,
        staticImports = []
    }: Partial = {}
) {
    let afterModule = '';
    const stylable = Stylable.create(stylableOptions);
    if (legacyRuntime && runtimePath === '@stylable/runtime') {
        runtimePath = '@stylable/runtime/cjs/index-legacy';
        afterModule += 'module.exports.default = module.exports;';
    }
    return function stylableToModule(source: string, path: string) {
        const res = stylable.transform(source, path);
        return generateModuleSource(
            res,
            runtimeStylesheetId === 'module' ? 'module.id' : res.meta.namespace,
            [
                ...staticImports.map(request => `import ${JSON.stringify(request)}`),
                `const runtime = require(${JSON.stringify(runtimePath)})`
            ],
            `runtime.$`,
            `runtime.create`,
            `runtime.createRenderable`,
github wix / stylable / packages / node / src / stylable-module-factory.ts View on Github external
export function stylableModuleFactory(stylableOptions: StylableConfig, runtimePath?: string) {
    const stylable = Stylable.create(stylableOptions);

    return function stylableToModule(source: string, path: string) {
        return generateModuleSource(stylable.transform(source, path), true, runtimePath);
    };
}