esbuild-css-modules-plugin
Advanced tools
Comparing version 3.0.0-dev.7 to 3.0.0-dev.8
@@ -18,4 +18,2 @@ import { basename, dirname, extname, normalize, relative, resolve, sep } from 'node:path'; | ||
// TODO not generate inject code on load, but on end | ||
/** | ||
@@ -22,0 +20,0 @@ * @type {(options: import('./index.js').Options) => import('esbuild').Plugin} |
@@ -10,3 +10,3 @@ import { bundle as bundleModulesCss } from 'lightningcss'; | ||
} from './utils.js'; | ||
import { camelCase, sortBy, uniq, upperFirst } from 'lodash-es'; | ||
import { camelCase, sortBy, uniq, uniqBy, upperFirst } from 'lodash-es'; | ||
import { injectorVirtualPath, pluginJsNamespace } from './utils.js'; | ||
@@ -164,5 +164,7 @@ | ||
/** @type {Set<string>} */ | ||
const nameSet = new Set(); | ||
/** @type {[string, string][]} */ | ||
const jsNames = []; | ||
/** @type {[string, string][]} */ | ||
@@ -185,9 +187,15 @@ const originNames = []; | ||
} | ||
jsLines.push(`export const ${jsName} = "${localName}";`); | ||
if (!nameSet.has(jsName)) { | ||
jsLines.push(`export const ${jsName} = "${localName}";`); | ||
} | ||
} | ||
jsNames.push([jsName, supportNamedExports ? jsName : `"${localName}"`]); | ||
if (keepOrigin && origin !== jsName) { | ||
originNames.push([origin, supportNamedExports ? jsName : `"${localName}"`]); | ||
nameSet.add(origin); | ||
} | ||
nameSet.add(jsName); | ||
}); | ||
@@ -201,3 +209,3 @@ | ||
export default new Proxy({ | ||
${uniq([...jsNames, ...originNames]) | ||
${uniqBy([...jsNames, ...originNames], '0') | ||
.map(([o, l]) => ` "${o}": ${l}`) | ||
@@ -215,3 +223,3 @@ .join(',\n')} | ||
export default { | ||
${uniq([...jsNames, ...originNames]) | ||
${uniqBy([...jsNames, ...originNames], '0') | ||
.map(([o, l]) => ` "${o}": ${l}`) | ||
@@ -218,0 +226,0 @@ .join(',\n')} |
{ | ||
"name": "esbuild-css-modules-plugin", | ||
"version": "3.0.0-dev.7", | ||
"version": "3.0.0-dev.8", | ||
"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
46048
1148