How to use @stylable/module-utils - 4 common examples

To help you get started, we’ve selected a few @stylable/module-utils 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 / jest / src / jest.ts View on Github external
export function processFactory(
    stylableConfig?: Partial,
    factoryOptions?: Partial
) {
    return stylableModuleFactory(
        {
            fileSystem: fs,
            requireModule: require,
            projectRoot: '',
            ...stylableConfig
        },
        // ensure the generated module points to our own @stylable/runtime copy
        // this allows @stylable/jest to be used as part of a globally installed CLI
        { runtimePath: stylableRuntimePath, ...factoryOptions }
    );
}
github wix / stylable / packages / webpack-plugin / src / stylable-generator.ts View on Github external
public createModuleSource(
        module: StylableModule,
        moduleId: string,
        stylableResult: StylableResults,
        css: string,
        depth: string | number,
        renderableOnly = false
    ) {
        const moduleSource = generateModuleSource(
            stylableResult,
            moduleId,
            [],
            this.options.includeCSSInJS ? `${WEBPACK_STYLABLE}.$` : 'null',
            `${WEBPACK_STYLABLE}.create`,
            `${WEBPACK_STYLABLE}.createRenderable`,
            css,
            typeof depth === 'number' ? depth.toString() : depth,
            'module.' + module.exportsArgument,
            this.options.experimentalHMR
                ? `/* Webpack HMR */ if (module && module.hot) { module.hot.accept(); }`
                : '',
            renderableOnly
        );

        return new OriginalSource(moduleSource, module.resource);
github wix / stylable / packages / node / src / require-hook.ts View on Github external
export function attachHook({
    matcher,
    afterCompile,
    stylableConfig,
    runtimePath,
    ignoreJSModules,
    legacyRuntime
}: Partial = {}) {
    const stylableToModule = stylableModuleFactory(
        {
            projectRoot: 'root',
            fileSystem: fs,
            requireModule: require,
            resolveNamespace,
            ...stylableConfig
        },
        { runtimePath, legacyRuntime }
    );

    if (!matcher) {
        matcher = defaultStylableMatcher;
    }

    const prevHook = require.extensions[HOOK_EXTENSION];
    require.extensions[HOOK_EXTENSION] = function cssModulesHook(m: any, filename: string) {
github wix / stylable / packages / cli / src / build.ts View on Github external
() =>
                createModuleSource(
                    res,
                    format,
                    includeCSSInJS,
                    undefined,
                    undefined,
                    undefined,
                    injectCSSRequest ? [`./${cssAssetFilename}`] : [],
                    compat ? '@stylable/runtime/cjs/index-legacy' : '@stylable/runtime',
                    compat ? ['module.exports.default = module.exports;'] : []
                ),
            `Transform Error: ${filePath}`

@stylable/module-utils

Stylable module creation utilities

MIT
Latest version published 7 months ago

Package Health Score

62 / 100
Full package analysis

Similar packages