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

esbuild-css-modules-plugin

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-css-modules-plugin - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

changelog.md

34

index.js

@@ -18,3 +18,7 @@ const path = require('path');

const getAbsoluteUrl = (resolveDir, url) => {
return path.resolve(resolveDir, url.replace(/\"/g, '').replace(/\'/g, ''));
const pureUrl = url.replace(/\"/g, '').replace(/\'/g, '');
if (path.isAbsolute(pureUrl) || pureUrl.startsWith('http')) {
return pureUrl;
}
return path.resolve(resolveDir, pureUrl);
};

@@ -24,6 +28,8 @@

const resolveDir = path.dirname(cssFullPath);
const cssContent = await readFile(cssFullPath);
const transformConfig = {
filename: path.basename(cssFullPath),
code: cssContent,
/**
* @type {import('@parcel/css').BundleOptions}
*/
const bundleConfig = {
filename: cssFullPath,
minify: false,

@@ -34,3 +40,4 @@ sourceMap: true,

};
const { code, exports, map, dependencies } = cssHandler.transform(transformConfig);
const { code, exports = {}, map, dependencies = [] } = cssHandler.bundle(bundleConfig);
const cssModulesJSON = {};

@@ -40,7 +47,6 @@ Object.keys(exports).forEach((originClass) => {

});
const classNames = JSON.stringify(cssModulesJSON);
const jsContent = `
export default ${classNames};
`;
const urls = dependencies?.filter((d) => d.type === 'url') ?? [];
const classNames = JSON.stringify(cssModulesJSON, null, 2);
const urls = dependencies.filter((d) => d.type === 'url');
let finalCssContent = code.toString('utf-8');

@@ -53,2 +59,5 @@ urls.forEach(({ url, placeholder }) => {

});
const jsContent = `export default ${classNames};`;
if (map) {

@@ -163,3 +172,4 @@ finalCssContent += `\n/*# sourceMappingURL=data:application/json;base64,${map.toString(

return {
contents: jsFileContent
contents: jsFileContent,
loader: 'js'
};

@@ -166,0 +176,0 @@ });

{
"name": "esbuild-css-modules-plugin",
"version": "2.1.2",
"version": "2.1.3",
"description": "A esbuild plugin to bundle css modules into js(x)/ts(x).",

@@ -21,13 +21,13 @@ "main": "index.js",

},
"devDependencies": {
"esbuild": "^0.14.11"
"peerDependencies": {
"esbuild": "^0.14.21"
},
"dependencies": {
"@parcel/css": "^1.0.1",
"@parcel/css": "^1.3.1",
"fs-extra": "^9.1.0",
"lodash": "^4.17.21",
"postcss": "^8.2.7",
"postcss-modules": "^4.0.0",
"postcss": "^8.4.6",
"postcss-modules": "^4.3.0",
"tmp": "^0.2.1"
}
}
import React from 'react';
import styles, * as appCssModules from '../styles/app.modules.css';
import styles2, * as h from '../styles/deep/styles/hello.modules.css';

@@ -8,3 +7,3 @@ export const HelloWorld = () => (

<h3 className={styles.helloWorld}>Hello World!</h3>
<p className={styles2.helloText}>hi...</p>
<p className={styles.helloText}>hi...</p>
<pre>

@@ -14,8 +13,5 @@ <code>${appCssModules?.digest ?? '// n/a'}</code>

<pre>
<code>${h?.digest ?? '// n/a'}</code>
<code>${appCssModules?.css ?? '// n/a'}</code>
</pre>
<pre>
<code>${h?.css ?? '// n/a'}</code>
</pre>
</>
);

Sorry, the diff of this file is not supported yet

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