Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))}
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) => {
const outputs = ({ exports }) => `module.exports = ${
JSON.stringify(output.join(exports), null, 4)
};`;