esbuild-css-modules-plugin
Advanced tools
Comparing version 2.6.1-beta.1 to 2.6.2
@@ -110,7 +110,7 @@ const path = require('path'); | ||
/** | ||
* getPackageVersion | ||
* getPackageInfo | ||
* @param {import('..').Build} build | ||
* @returns {string} | ||
* @returns {{name: string; version: string;}} | ||
*/ | ||
const getPackageVersion = (build) => { | ||
const getPackageInfo = (build) => { | ||
const rootDir = getRootDir(build); | ||
@@ -120,5 +120,5 @@ const packageJsonFile = path.resolve(rootDir, './package.json'); | ||
fs.accessSync(packageJsonFile, fs.constants.R_OK); | ||
return require(packageJsonFile).version ?? ''; | ||
return require(packageJsonFile); | ||
} catch (error) { | ||
return ''; | ||
return { name: '', version: '' }; | ||
} | ||
@@ -128,2 +128,11 @@ }; | ||
/** | ||
* getPackageVersion | ||
* @param {import('..').Build} build | ||
* @returns {string} | ||
*/ | ||
const getPackageVersion = (build) => { | ||
return getPackageInfo(build).version; | ||
}; | ||
/** | ||
* getRelativePath | ||
@@ -152,3 +161,3 @@ * @description get relative path from build root | ||
const buildRoot = getRootDir(build); | ||
const packageVersion = getPackageVersion(build); | ||
const { version: packageVersion, name: packageName } = getPackageInfo(build); | ||
let entries = []; | ||
@@ -164,10 +173,12 @@ if (Array.isArray(entryPoints)) { | ||
} | ||
const entryContents = packageVersion + ( | ||
await Promise.all( | ||
entries.map(async (p) => { | ||
const absPath = path.isAbsolute(p) ? p : path.resolve(buildRoot, p); | ||
return (await readFile(absPath, { encoding: 'utf8' })).trim(); | ||
}) | ||
) | ||
).join(''); | ||
const entryContents = | ||
`// ${packageName}@${packageVersion}\n` + | ||
( | ||
await Promise.all( | ||
entries.map(async (p) => { | ||
const absPath = path.isAbsolute(p) ? p : path.resolve(buildRoot, p); | ||
return (await readFile(absPath, { encoding: 'utf8' })).trim(); | ||
}) | ||
) | ||
).join('\n'); | ||
return createHash('sha256').update(entryContents).digest('hex'); | ||
@@ -246,3 +257,4 @@ }; | ||
validateNamedExport, | ||
getPackageInfo, | ||
getPackageVersion | ||
}; |
{ | ||
"name": "esbuild-css-modules-plugin", | ||
"version": "2.6.1-beta.1", | ||
"version": "2.6.2", | ||
"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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
38441
1018
1