esbuild-css-modules-plugin
Advanced tools
Comparing version 3.0.0-dev.4 to 3.0.0-dev.5
@@ -9,3 +9,2 @@ import { | ||
} from 'node:path'; | ||
import { createHash } from 'node:crypto'; | ||
import { readFile, writeFile, mkdir } from 'node:fs/promises'; | ||
@@ -26,3 +25,4 @@ import { | ||
pluginCssNamespace, | ||
relativeToCwd | ||
relativeToCwd, | ||
genDigest | ||
} from './utils.js'; | ||
@@ -141,6 +141,8 @@ import { transform, bundle } from 'lightningcss'; | ||
const { log, relative, buildRoot, packageVersion } = patchedBuild.context; | ||
const { log, relative, buildRoot, packageVersion, buildId } = patchedBuild.context; | ||
const supportNamedExports = options.namedExports ?? false; | ||
const isEsbuildBundleMode = build.initialOptions.bundle ?? false; | ||
const genTheDigest = (/** @type {string} */ str) => genDigest(str, buildId); | ||
patchedBuild.onLoad( | ||
@@ -354,5 +356,3 @@ { filter: /.*/, namespace: pluginCssNamespace }, | ||
define: { | ||
[digestPlaceholder]: JSON.stringify( | ||
createHash('md5').update(relativeFilePath).digest('hex') | ||
), | ||
[digestPlaceholder]: JSON.stringify(genTheDigest(relativeFilePath)), | ||
[contentsPlaceholder]: JSON.stringify(result.code.toString('utf8').replaceAll('\n', '')) | ||
@@ -438,5 +438,3 @@ } | ||
const digest = createHash('md5') | ||
.update(baseNames.join('') + pluginJsNamespace) | ||
.digest('hex'); | ||
const digest = genTheDigest(baseNames.join('')); | ||
@@ -443,0 +441,0 @@ const cssContents = cssOutputs.map((opt) => opt.text.trim()).join(''); |
@@ -37,3 +37,2 @@ import { isAbsolute, resolve, sep, relative } from 'node:path'; | ||
/** | ||
@@ -203,3 +202,3 @@ * getRootDir | ||
/** | ||
* @param {string} to | ||
* @param {string} to | ||
* @returns string | ||
@@ -209,2 +208,5 @@ */ | ||
const genDigest = (/** @type {string} */ str, /** @type {string} */ buildId) => | ||
createHash('md5').update(`${pluginName}:${buildId}:${str}`).digest('hex'); | ||
export { | ||
@@ -227,3 +229,4 @@ pluginName, | ||
digestPlaceholder, | ||
relativeToCwd | ||
relativeToCwd, | ||
genDigest | ||
}; |
{ | ||
"name": "esbuild-css-modules-plugin", | ||
"version": "3.0.0-dev.4", | ||
"version": "3.0.0-dev.5", | ||
"description": "A esbuild plugin to bundle css modules into js(x)/ts(x).", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31430