Skip to content

Commit d441e40

Browse files
author
Ives van Hoorne
committed
Fix css cache
1 parent 39d92b1 commit d441e40

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/sandbox/eval/transpiled-module.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export type LoaderContext = {
5959
options: ?{
6060
isAbsolute: boolean,
6161
}
62-
) => TranspiledModule, // eslint-disable-line no-use-before-define
62+
) => ?TranspiledModule, // eslint-disable-line no-use-before-define
6363
addDependenciesInDirectory: (
6464
depPath: string,
6565
options: {
@@ -252,7 +252,7 @@ export default class TranspiledModule {
252252
depPath.startsWith('babel-runtime') ||
253253
depPath.startsWith('codesandbox-api')
254254
) {
255-
return;
255+
return null;
256256
}
257257

258258
try {
@@ -497,10 +497,18 @@ export default class TranspiledModule {
497497
}
498498

499499
postEvaluate(manager: Manager) {
500+
// For non cacheable transpilers we remove the cached evaluation
501+
if (
502+
manager.preset
503+
.getLoaders(this.module, this.query)
504+
.some(t => !t.transpiler.cacheable)
505+
) {
506+
this.compilation = null;
507+
}
508+
500509
// There are no other modules calling this module, so we run a function on
501510
// all transpilers that clears side effects if there are any. Example:
502511
// Remove CSS styles from the dom.
503-
504512
if (this.initiators.size === 0 && !this.isEntry) {
505513
manager.preset.getLoaders(this.module, this.query).forEach(t => {
506514
t.transpiler.cleanModule(this.getLoaderContext(manager, t.options));

0 commit comments

Comments
 (0)