Skip to content

Commit

Permalink
Merge pull request #2092 from embroider-build/dont-move-html
Browse files Browse the repository at this point in the history
Don't move index.html
  • Loading branch information
ef4 committed Sep 2, 2024
2 parents eb93cd5 + 03ed783 commit bd04b35
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 65 deletions.
12 changes: 4 additions & 8 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,10 @@ export class CompatAppBuilder {
return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js', '.gjs', '.gts'];
}

private addEmberEntrypoints(htmlTreePath: string): string[] {
let classicEntrypoints = ['index.html', 'tests/index.html'];
if (!this.compatApp.shouldBuildTests) {
classicEntrypoints.pop();
}
private addEmberEntrypoints(): string[] {
let classicEntrypoints = ['index.html'];
for (let entrypoint of classicEntrypoints) {
let sourcePath = join(htmlTreePath, entrypoint);
let sourcePath = join(this.compatApp.root, entrypoint);
let rewrittenAppPath = join(this.root, entrypoint);
writeFileSync(rewrittenAppPath, readFileSync(sourcePath));
}
Expand Down Expand Up @@ -463,7 +460,7 @@ export class CompatAppBuilder {
}

let appFiles = this.updateAppJS(inputPaths.appJS);
let assetPaths = this.addEmberEntrypoints(inputPaths.htmlTree);
let assetPaths = this.addEmberEntrypoints();

if (this.activeFastboot) {
// when using fastboot, our own package.json needs to be in the output so fastboot can read it.
Expand Down Expand Up @@ -741,7 +738,6 @@ function addCachablePlugin(babelConfig: TransformOptions) {

interface TreeNames {
appJS: BroccoliNode;
htmlTree: BroccoliNode;
publicTree: BroccoliNode | undefined;
configTree: BroccoliNode;
}
44 changes: 0 additions & 44 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ export default class CompatApp {
return require(resolve.sync(specifier, { basedir: this.emberCLILocation }));
}

private get configReplace() {
return this.requireFromEmberCLI('broccoli-config-replace');
}

private get configLoader() {
return this.requireFromEmberCLI('broccoli-config-loader');
}
Expand Down Expand Up @@ -184,45 +180,6 @@ export default class CompatApp {
};
}

private get htmlTree() {
if (this.legacyEmberAppInstance.tests) {
return mergeTrees([this.indexTree, this.testIndexTree]);
} else {
return this.indexTree;
}
}

private get indexTree() {
let indexFilePath = this.legacyEmberAppInstance.options.outputPaths.app.html;
let index = buildFunnel(this.legacyEmberAppInstance.trees.app, {
allowEmpty: true,
include: [`index.html`],
getDestinationPath: () => indexFilePath,
annotation: 'app/index.html',
});
return new this.configReplace(index, this.configTree, {
configPath: join('environments', `${this.legacyEmberAppInstance.env}.json`),
files: [indexFilePath],
patterns: this.filteredPatternsByContentFor.others,
annotation: 'ConfigReplace/indexTree',
});
}

private get testIndexTree() {
let index = buildFunnel(this.legacyEmberAppInstance.trees.tests, {
allowEmpty: true,
include: [`index.html`],
destDir: 'tests',
annotation: 'tests/index.html',
});
return new this.configReplace(index, this.configTree, {
configPath: join('environments', `test.json`),
files: ['tests/index.html'],
patterns: this.filteredPatternsByContentFor.others,
annotation: 'ConfigReplace/testIndexTree',
});
}

@Memoize()
babelConfig(): TransformOptions {
// this finds all the built-in babel configuration that comes with ember-cli-babel
Expand Down Expand Up @@ -727,7 +684,6 @@ export default class CompatApp {

return {
appJS: this.processAppJS().appJS,
htmlTree: this.htmlTree,
publicTree,
configTree,
contentForTree,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions tests/scenarios/compat-addon-classic-features-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ appScenarios
});
};
`,
app: {
'index.html': `
'index.html': `
<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -93,7 +92,6 @@ appScenarios
</body>
</html>
`,
},
});
})
.forEachScenario(scenario => {
Expand Down
12 changes: 2 additions & 10 deletions tests/scenarios/compat-app-html-attributes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ const { module: Qmodule, test } = QUnit;

appScenarios
.map('compat-app-script-attributes', app => {
let appFolder = app.files.app;

if (appFolder === null || typeof appFolder !== 'object') {
throw new Error('app folder unexpectedly missing');
}

let indexHtml = appFolder['index.html'];
let indexHtml = app.files['index.html'];

if (typeof indexHtml !== 'string') {
throw new Error('index.html unexpectedly missing');
Expand All @@ -38,9 +32,7 @@ appScenarios
indexHtml = indexHtml.replace(/<script /g, '<script defer ');

app.mergeFiles({
app: {
'index.html': indexHtml,
},
'index.html': indexHtml,
});
})
.forEachScenario(scenario => {
Expand Down
File renamed without changes.

0 comments on commit bd04b35

Please sign in to comment.