Skip to content

Commit

Permalink
Merge pull request #1921 from embroider-build/new-index-html-format-t…
Browse files Browse the repository at this point in the history
…est-support-css

New `index.html` format - `test-support.css`, `vendor.css`
  • Loading branch information
mansona authored May 16, 2024
2 parents bdf4aae + 47016ad commit d7336b2
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 58 deletions.
7 changes: 0 additions & 7 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ export class CompatAppBuilder {
javascript: this.compatApp.findAppScript(scripts, entrypoint),
styles: this.compatApp.findAppStyles(styles, entrypoint),
implicitScripts: this.compatApp.findVendorScript(scripts, entrypoint),
implicitStyles: this.compatApp.findVendorStyles(styles, entrypoint),
testJavascript: this.compatApp.findTestScript(scripts),
implicitTestStyles: this.compatApp.findTestSupportStyles(styles),
};
},
};
Expand Down Expand Up @@ -464,9 +462,6 @@ export class CompatAppBuilder {
}
}

// virtual vendor.css entrypoint
html.insertStyleLink(html.implicitStyles, '@embroider/core/vendor.css');

if (!asset.fileAsset.includeTests) {
return;
}
Expand All @@ -475,8 +470,6 @@ export class CompatAppBuilder {

let testJS = this.testJSEntrypoint(appFiles, prepared);
html.insertScriptTag(html.testJavascript, testJS.relativePath, { type: 'module' });

html.insertStyleLink(html.implicitTestStyles, '@embroider/core/test-support.css');
}

// recurse to find all active addons that don't cross an engine boundary.
Expand Down
19 changes: 0 additions & 19 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,25 +738,6 @@ export default class CompatApp {
);
}

findVendorStyles(styles: HTMLLinkElement[], entrypoint: string): HTMLLinkElement {
let vendorStyle = styles.find(
style => this.withoutRootURL(style.href) === this.legacyEmberAppInstance.options.outputPaths.vendor.css
);
return throwIfMissing(
vendorStyle,
this.legacyEmberAppInstance.options.outputPaths.vendor.css,
styles.map(s => s.href),
entrypoint,
'vendor css'
);
}

findTestSupportStyles(styles: HTMLLinkElement[]): HTMLLinkElement | undefined {
return styles.find(
style => this.withoutRootURL(style.href) === this.legacyEmberAppInstance.options.outputPaths.testSupport.css
);
}

findTestScript(scripts: HTMLScriptElement[]): HTMLScriptElement | undefined {
return scripts.find(
script => this.withoutRootURL(script.src) === this.legacyEmberAppInstance.options.outputPaths.tests.js
Expand Down
17 changes: 1 addition & 16 deletions packages/core/src/ember-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface EmberHTML {
javascript: Node;
styles: Node;
implicitScripts: Node;
implicitStyles: Node;

// these are optional because you *may* choose to stick your implicit test
// things into specific locations (which we need for backward-compat). But you
Expand All @@ -22,7 +21,6 @@ export interface EmberHTML {
// Do not confuse these with controlling whether or not we will insert tests.
// That is separately controlled via `includeTests`.
testJavascript?: Node;
implicitTestStyles?: Node;
}

class Placeholder {
Expand Down Expand Up @@ -81,34 +79,21 @@ export class PreparedEmberHTML {
javascript: Placeholder;
styles: Placeholder;
implicitScripts: Placeholder;
implicitStyles: Placeholder;
testJavascript: Placeholder;
implicitTestStyles: Placeholder;

constructor(private asset: EmberAsset) {
this.dom = new JSDOM(readFileSync(asset.sourcePath, 'utf8'));
let html = asset.prepare(this.dom);
this.javascript = Placeholder.replacing(html.javascript);
this.styles = Placeholder.replacing(html.styles);
this.implicitScripts = Placeholder.find(html.implicitScripts);
this.implicitStyles = Placeholder.replacing(html.implicitStyles);
this.testJavascript = html.testJavascript
? Placeholder.replacing(html.testJavascript)
: Placeholder.immediatelyAfter(this.javascript.end);
this.implicitTestStyles = html.implicitTestStyles
? Placeholder.replacing(html.implicitTestStyles)
: Placeholder.immediatelyAfter(this.implicitStyles.end);
}

private placeholders(): Placeholder[] {
return [
this.javascript,
this.styles,
this.implicitScripts,
this.implicitStyles,
this.implicitTestStyles,
this.testJavascript,
];
return [this.javascript, this.styles, this.implicitScripts, this.testJavascript];
}

clear() {
Expand Down
2 changes: 1 addition & 1 deletion packages/util/tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">

{{content-for "head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion test-packages/sample-transforms/tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">

{{content-for "head-footer"}}
Expand Down
4 changes: 2 additions & 2 deletions test-packages/sample-transforms/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{{content-for "head"}}
{{content-for "test-head"}}

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/addon-template/tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">

{{content-for "head-footer"}}
Expand Down
4 changes: 2 additions & 2 deletions tests/addon-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
{{content-for "head"}}
{{content-for "test-head"}}

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/app-template/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/app-template.css">

{{content-for "head-footer"}}
Expand Down
4 changes: 2 additions & 2 deletions tests/app-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

{{content-for "head"}} {{content-for "test-head"}}

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css" />
<link rel="stylesheet" href="/@embroider/core/vendor.css" />
<link rel="stylesheet" href="{{rootURL}}assets/app-template.css" />
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css" />
<link rel="stylesheet" href="/@embroider/core/test-support.css" />

{{content-for "head-footer"}} {{content-for "test-head-footer"}}
</head>
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/macro-test/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{{content-for "head"}}
{{content-for "test-head"}}

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/app-template.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/compat-addon-classic-features-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ appScenarios
{{content-for "head"}}
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/app-template.css">
{{content-for "head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/ts-app-template/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/ts-app-template.css">

{{content-for "head-footer"}}
Expand Down
4 changes: 2 additions & 2 deletions tests/ts-app-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
{{content-for "head"}}
{{content-for "test-head"}}

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/ts-app-template.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
Expand Down

0 comments on commit d7336b2

Please sign in to comment.