How to use the @modular-css/processor/lib/output.js.join function in @modular-css/processor

To help you get started, we’ve selected a few @modular-css/processor 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 tivac / modular-css / packages / rollup / rollup.js View on Github external
log("transform", id);

            let processed;

            try {
                processed = await processor.string(id, code);
            } catch(e) {
                // Replace the default message with the much more verbose one
                e.message = e.toString();

                return this.error(e);
            }

            const { details, exports } = processed;

            const exported = output.join(exports);
            const relative = path.relative(processor.options.cwd, id);
            const dependencies = processor.dependencies(id);

            const out = [
                dev ?
                    dedent(`
                        const data = ${JSON.stringify(exported)};

                        export default new Proxy(data, {
                            get(tgt, key) {
                                if(key in tgt) {
                                    return tgt[key];
                                }

                                throw new ReferenceError(
                                    key + " is not exported by " + ${JSON.stringify(slash(relative))}
github tivac / modular-css / packages / webpack / loader.js View on Github external
this.options.processor :
        // Webpack 4
        this._compiler.options.processor;

    if(options.cjs) {
        this.emitWarning(
            new Error("cjs option is deprecated, used namedExports: false instead")
        );
    }

    this.cacheable();

    try {
        const result = await processor.string(this.resourcePath, source);

        const exported = output.join(result.exports);
        const out = [];

        if(options.defaultExport) {
            out.push(`export default ${JSON.stringify(exported, null, 4)};`);
        }

        processor.dependencies(this.resourcePath).forEach(this.addDependency);

        // Just default object export in this case
        if(!options.namedExports) {
            return done(null, out.join("\n"));
        }

        // Warn if any of the exported CSS wasn't able to be used as a valid JS identifier
        // and exclude from the output
        Object.keys(exported).forEach((ident) => {
github tivac / modular-css / packages / browserify / browserify.js View on Github external
const outputs = ({ exports }) => `module.exports = ${
    JSON.stringify(output.join(exports), null, 4)
};`;

@modular-css/processor

A streamlined reinterpretation of CSS Modules

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis