Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rspack/plugin-postcss

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rspack/plugin-postcss - npm Package Compare versions

Comparing version 0.0.0-ba4640261-20221114041841 to 0.0.0-bcf6bbc44-20221125091333

10

CHANGELOG.md
# rspack-plugin-postcss
## 0.0.0-ba4640261-20221114041841
## 0.0.0-bcf6bbc44-20221125091333
### Patch Changes
- @rspack/binding@0.0.0-ba4640261-20221114041841
- @rspack/binding@0.0.0-bcf6bbc44-20221125091333
## 0.0.10
### Patch Changes
- @rspack/binding@0.0.10
## 0.0.9

@@ -10,0 +16,0 @@

13

package.json
{
"name": "@rspack/plugin-postcss",
"version": "0.0.0-ba4640261-20221114041841",
"version": "0.0.0-bcf6bbc44-20221125091333",
"description": "",

@@ -8,12 +8,7 @@ "main": "src/index.js",

"dependencies": {
"@rspack/binding": "0.0.0-ba4640261-20221114041841",
"postcss-modules": "^5.0.0",
"postcss-pxtorem": "^6.0.0"
"postcss-pxtorem": "^6.0.0",
"postcss": "^8.4.16",
"@rspack/binding": "0.0.0-bcf6bbc44-20221125091333"
},
"peerDependencies": {
"postcss": "^7.0.0 || ^8.0.1"
},
"devDependencies": {
"postcss": "^8.4.16"
},
"author": "",

@@ -20,0 +15,0 @@ "license": "ISC",

@@ -9,7 +9,10 @@ const { Processor } = require("postcss");

module.exports = async function loader(loaderContext) {
const IS_MODULES = /\.module(s)?\.\w+$/i;
module.exports = async function loader(content, sourceMap) {
const callback = this.async();
// TODO: customize options, until js binding support this functionality
// console.log(loaderContext.getOptions());
let options = loaderContext.getOptions() ?? {};
let enableModules = options.modules;
// console.log(this.getOptions());
let options = this.getOptions() ?? {};
let modulesOptions = options.modules;
let pxToRem = options.pxToRem;

@@ -19,5 +22,5 @@ let useSourceMap =

? options.sourceMap
: loaderContext.useSourceMap;
: this.sourceMap;
try {
let meta = "";
let additionalData;
let plugins = [];

@@ -30,4 +33,4 @@ let enablePxToRem = false;

let processOptions = {
from: loaderContext.resourcePath,
to: loaderContext.resourcePath
from: this.resourcePath,
to: this.resourcePath
};

@@ -47,12 +50,29 @@

if (enableModules) {
plugins.push(
cssModules({
getJSON(_, json) {
if (json) {
meta = json;
if (modulesOptions) {
let auto =
typeof modulesOptions === "boolean"
? true
: modulesOptions.auto ?? true;
let isModules;
if (typeof auto === "boolean") {
isModules = auto && IS_MODULES.test(this.resourcePath);
} else if (auto instanceof RegExp) {
isModules = auto.test(this.resourcePath);
} else if (typeof auto === "function") {
isModules = auto(this.resourcePath);
}
delete modulesOptions.auto;
if (isModules) {
plugins.push(
cssModules({
...modulesOptions,
getJSON(_, json) {
if (json) {
additionalData = json;
}
}
}
})
);
})
);
}
}

@@ -66,28 +86,18 @@

}
if (loaderContext.sourceMap && processOptions.map) {
processOptions.map.prev = normalizeSourceMap(
loaderContext.sourceMap,
loaderContext.context
);
if (sourceMap && processOptions.map) {
processOptions.map.prev = normalizeSourceMap(sourceMap, this.context);
}
let root = new Processor(plugins);
let res = await root.process(
loaderContext.source.getCode(),
processOptions
);
let res = await root.process(content, processOptions);
let map = res.map ? res.map.toJSON() : undefined;
if (map && useSourceMap) {
map = normalizeSourceMapAfterPostcss(map, loaderContext.context);
map = normalizeSourceMapAfterPostcss(map, this.context);
}
return {
content: res.css,
meta: meta ? Buffer.from(JSON.stringify(meta)) : "",
sourceMap: map
};
callback(null, res.css, map, additionalData);
} catch (err) {
throw new Error(err);
callback(err, "");
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc