Skip to content

Commit

Permalink
fix: reset HTMLEntrypoint state after build (fix embroider-build#1211)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobq committed Jun 3, 2022
1 parent aec11b7 commit b7c45af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/src/html-entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Placeholder from './html-placeholder';
import { Variant } from './packager';

export class HTMLEntrypoint {
private dom: JSDOM;
private dom!: JSDOM;
private placeholders: Map<string, Placeholder[]> = new Map();
modules: string[] = [];
scripts: string[] = [];
Expand All @@ -20,6 +20,10 @@ export class HTMLEntrypoint {
private publicAssetURL: string,
public filename: string
) {
this.initialize();
}

initialize() {
this.dom = new JSDOM(readFileSync(join(this.pathToVanillaApp, this.filename), 'utf8'));

for (let tag of this.handledStyles()) {
Expand Down
4 changes: 4 additions & 0 deletions packages/webpack/src/ember-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ const Webpack: PackagerConstructor<Options> = class Webpack implements Packager
compiler.hooks.done.tapPromise('EmbroiderPlugin', async stats => {
this.summarizeStats(stats, variant, variantIndex);
await this.writeFiles(this.bundleSummary, appInfo, variantIndex);
// If this webpack instance / appInfo will be reused for a
// subsequent build then we need to be careful not to reuse the
// internal JSDOM state encapsulated within it.
appInfo.entrypoints.forEach(ep => ep.initialize());
});
},
],
Expand Down

0 comments on commit b7c45af

Please sign in to comment.