Skip to content

Commit e250a07

Browse files
nicknisiCompuIves
authored andcommitted
fix widget styles loading in dojo widgets (codesandbox#1066)
Use an existing generated CSS modules JS file if it exists.
1 parent 2db6f66 commit e250a07

File tree

1 file changed

+7
-4
lines changed
  • packages/app/src/sandbox/eval/presets/dojo/transpilers

1 file changed

+7
-4
lines changed

packages/app/src/sandbox/eval/presets/dojo/transpilers/style.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ class DojoStyleTranspiler extends StyleTranspiler {
1212
async doTranspilation(code: string, loaderContext: LoaderContext) {
1313
const id = getStyleId(loaderContext._module.getId());
1414
const { path } = loaderContext;
15-
const { code: packageJson } = loaderContext
16-
.getModules()
17-
.find(module => module.path === '/package.json');
15+
const modules = loaderContext.getModules();
16+
let result = modules.find(module => module.path === `${path}.js`);
17+
if (result) {
18+
return { transpiledCode: `${insertCss(id, code)}\n${result.code}` };
19+
}
20+
const { code: packageJson } = modules.find(module => module.path === '/package.json');
1821
const { name: packageName } = JSON.parse(packageJson);
1922
const [, baseName] = /\/([^/.]*)[^/]*$/.exec(path);
2023
const key = `${packageName}/${baseName}`;
2124
const { css, exportTokens } = await getModules(code, loaderContext);
22-
let result = insertCss(id, css);
25+
result = insertCss(id, css);
2326
result += `\nmodule.exports=${JSON.stringify({
2427
' _key': key,
2528
...exportTokens,

0 commit comments

Comments
 (0)