-
Notifications
You must be signed in to change notification settings - Fork 18
v3.1.5: Fix #75 #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v3.1.5: Fix #75 #76
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ export const setup = (build, _options) => { | |
const rpath = relative(buildRoot, path); | ||
const prefix = basename(rpath, extname(path)) | ||
.replace(/[^a-zA-Z0-9]/g, '-') | ||
.replace(/^\-*/, ''); | ||
.replace(/^-*/, ''); | ||
const suffix = patchedBuild.context.packageVersion?.replace(/[^a-zA-Z0-9]/g, '') ?? ''; | ||
|
||
const buildResult = CSSTransformer.getInstance(patchedBuild).bundle(path, { | ||
|
@@ -320,7 +320,9 @@ export const setup = (build, _options) => { | |
/** @type {[string, string][]} */ | ||
const filesToBuild = []; | ||
warnMetafile(); | ||
const cssOutputsMap = Object.entries(r.metafile?.outputs ?? {}).reduce((m, [o, { inputs }]) => { | ||
|
||
const cssOutputsMap = Object.entries(r.metafile?.outputs ?? {}) | ||
.reduce(/** @type {(m: Record<string, string>, o: any) => Record<string, string>} */(m, [o, {inputs}]) => { | ||
Comment on lines
+324
to
+325
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing a typescript failure due to it not understanding the type of the accumulator. There could be a better solution to be quite honest. |
||
const keys = Object.keys(inputs); | ||
if (keys.length === 1 && new RegExp(`^${pluginCssNamespace}:.+\.css$`).test(keys[0])) { | ||
m[keys[0].replace(`${pluginCssNamespace}:`, '')] = o; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,15 @@ | |
.hello_world { | ||
color: red; | ||
background: url("../components/world.jpg"); | ||
|
||
animation: 3s linear slide-in; | ||
display: grid; | ||
grid-template: "image text"; | ||
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To test the hashing/not-hashing of the feature scoping controls. |
||
} | ||
|
||
.hello-world img { | ||
display: inline-block; | ||
grid-area: image; | ||
} | ||
|
||
.hello-world:hover { | ||
|
@@ -16,3 +21,17 @@ | |
.some-other-selector { | ||
background-image: url('../components/world.jpg'); | ||
} | ||
|
||
/* Should throw an error when `pure: true` */ | ||
div { | ||
border-radius: 20px; | ||
} | ||
|
||
@keyframes slide-in { | ||
from { | ||
margin-left: -20%; | ||
} | ||
to { | ||
margin-left: 100%; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.hello-text { | ||
composes: bg-red from "../../base.modules.css"; | ||
color: grey; | ||
grid-area: text; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ import cssModulesPlugin from '../index.js'; | |
plugins: [ | ||
cssModulesPlugin({ | ||
inject: '#my-custom-element-with-shadow-dom', | ||
emitDeclarationFile: true | ||
emitDeclarationFile: true, | ||
pattern: "__[hash]_[local]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LightningCSS complains if the pattern doesn't end with |
||
}) | ||
], | ||
metafile: true, | ||
|
@@ -56,7 +57,8 @@ import cssModulesPlugin from '../index.js'; | |
document.head.appendChild(styleEle); | ||
} | ||
`; | ||
} | ||
}, | ||
pattern: "__[hash]_[local]" | ||
}) | ||
], | ||
logLevel: 'debug' | ||
|
@@ -85,7 +87,9 @@ import cssModulesPlugin from '../index.js'; | |
cssModulesPlugin({ | ||
inject: false, | ||
namedExports: true, | ||
filter: /\.css$/i | ||
filter: /\.css$/i, | ||
pattern: "__[hash]_[local]" | ||
|
||
}) | ||
], | ||
logLevel: 'debug', | ||
|
@@ -112,7 +116,8 @@ import cssModulesPlugin from '../index.js'; | |
cssModulesPlugin({ | ||
inject: false, | ||
namedExports: true, | ||
emitDeclarationFile: true | ||
emitDeclarationFile: true, | ||
pattern: "__[hash]_[local]" | ||
}) | ||
], | ||
logLevel: 'debug', | ||
|
@@ -144,7 +149,8 @@ import cssModulesPlugin from '../index.js'; | |
}, | ||
force: true, | ||
forceInlineImages: true, | ||
inject: '#my-styles-container' | ||
inject: '#my-styles-container', | ||
pattern: "__[hash]_[local]" | ||
}) | ||
], | ||
logLevel: 'debug', | ||
|
@@ -169,14 +175,72 @@ import cssModulesPlugin from '../index.js'; | |
}, | ||
plugins: [ | ||
cssModulesPlugin({ | ||
inject: true | ||
inject: true, | ||
pattern: "__[hash]_[local]" | ||
}) | ||
], | ||
logLevel: 'debug', | ||
metafile: true | ||
}); | ||
console.log('[test][esbuild:bundle:splitting] done, please check `test/dist/bundle-splitting`', '\n'); | ||
|
||
try { | ||
// testing pure: true | ||
await esbuild.build({ | ||
entryPoints: ['app.jsx'], | ||
entryNames: '[name]-[hash]', | ||
format: 'esm', | ||
target: ['esnext'], | ||
bundle: true, | ||
minify: false, | ||
publicPath: 'https://my.domain/static/', | ||
external: ['react', 'react-dom'], | ||
outdir: './dist/pure', | ||
write: true, | ||
loader: { | ||
'.jpg': 'file' | ||
}, | ||
plugins: [ | ||
cssModulesPlugin({ | ||
pure: true, | ||
pattern: "__[hash]_[local]" | ||
}) | ||
], | ||
metafile: true, | ||
logLevel: 'debug' | ||
}); | ||
} catch (error) { | ||
console.log('Should result in " [ERROR] A selector in CSS modules should contain at least one class or ID selector [plugin esbuild-css-modules-plugin]"`', '\n'); | ||
} | ||
|
||
// testing feature scoping | ||
await esbuild.build({ | ||
entryPoints: ['app.jsx'], | ||
entryNames: '[name]-[hash]', | ||
format: 'esm', | ||
target: ['esnext'], | ||
bundle: true, | ||
minify: false, | ||
publicPath: 'https://my.domain/static/', | ||
external: ['react', 'react-dom'], | ||
outdir: './dist/feature-scoping', | ||
write: true, | ||
loader: { | ||
'.jpg': 'file' | ||
}, | ||
plugins: [ | ||
cssModulesPlugin({ | ||
animation: false, | ||
customIdents: false, | ||
grid: false, | ||
pattern: "__[hash]_[local]" | ||
}) | ||
], | ||
metafile: true, | ||
logLevel: 'debug' | ||
}); | ||
console.log('Should result in " [ERROR] A selector in CSS modules should contain at least one class or ID selector [plugin esbuild-css-modules-plugin]"`', '\n'); | ||
|
||
// testing no metafile & write false | ||
const r = await esbuild.build({ | ||
...buildOptions, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just removing an extraneous escape character