Skip to content

Commit

Permalink
Merge pull request #1922 from embroider-build/new-index-html-format-app
Browse files Browse the repository at this point in the history
New `index.html` format - entrypoint
  • Loading branch information
mansona authored May 16, 2024
2 parents c8b5bd4 + be5f83e commit 14b84ff
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 25 deletions.
6 changes: 0 additions & 6 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,6 @@ export class CompatAppBuilder {
});
}

// our tests entrypoint already includes a correct module dependency on the
// app, so we only insert the app when we're not inserting tests
if (!asset.fileAsset.includeTests) {
html.insertScriptTag(html.javascript, '@embroider/core/entrypoint', { type: 'module' });
}

if (this.fastbootConfig) {
// any extra fastboot app files get inserted into our html.javascript
// section, after the app has been inserted.
Expand Down
7 changes: 3 additions & 4 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,12 +727,11 @@ export default class CompatApp {
}

findAppScript(scripts: HTMLScriptElement[], entrypoint: string): HTMLScriptElement {
let appJS = scripts.find(
script => this.withoutRootURL(script.src) === this.legacyEmberAppInstance.options.outputPaths.app.js
);
let moduleName = '/@embroider/core/entrypoint';
let appJS = scripts.find(script => this.withoutRootURL(script.src) === moduleName);
return throwIfMissing(
appJS,
this.legacyEmberAppInstance.options.outputPaths.app.js,
moduleName,
scripts.map(s => s.src),
entrypoint,
'app javascript'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ember-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class PreparedEmberHTML {
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.javascript = Placeholder.find(html.javascript);
this.styles = Placeholder.replacing(html.styles);
this.implicitScripts = Placeholder.find(html.implicitScripts);
this.testJavascript = html.testJavascript
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 @@ -17,7 +17,7 @@
{{content-for "body"}}

<script src="/@embroider/core/vendor.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>

{{content-for "body-footer"}}
</body>
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 @@ -18,7 +18,7 @@
{{content-for "body"}}

<script src="/@embroider/core/vendor.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>

{{content-for "body-footer"}}
</body>
Expand Down
2 changes: 1 addition & 1 deletion test-packages/sample-transforms/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<script src="/testem.js" integrity=""></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-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 @@ -17,7 +17,7 @@
{{content-for "body"}}

<script src="/@embroider/core/vendor.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>

{{content-for "body-footer"}}
</body>
Expand Down
2 changes: 1 addition & 1 deletion tests/addon-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-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 @@ -17,7 +17,7 @@
{{content-for "body"}}

<script src="/@embroider/core/vendor.js"></script>
<script src="{{rootURL}}assets/app-template.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>

{{content-for "body-footer"}}
</body>
Expand Down
2 changes: 1 addition & 1 deletion tests/app-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="{{rootURL}}assets/app-template.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-footer"}} {{content-for "test-body-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/macro-test/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<script src="{{rootURL}}apple.js"></script>
<script src="{{rootURL}}ordered.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="{{rootURL}}assets/app-template.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-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 @@ -82,7 +82,7 @@ appScenarios
{{content-for "custom"}}
<script src="/@embroider/core/vendor.js"></script>
<script src="{{rootURL}}assets/app-template.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
{{content-for "body-footer"}}
</body>
Expand Down
6 changes: 3 additions & 3 deletions tests/scenarios/compat-app-html-attributes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ appScenarios

// <script ... src=".../vendor.js"> => <script ... src=".../vendor.js" data-original-filename="vendor.js">
indexHtml = indexHtml.replace('vendor.js">', 'vendor.js" data-original-filename="vendor.js">');
indexHtml = indexHtml.replace('app-template.js">', 'app-template.js" data-original-filename="app-template.js">');
indexHtml = indexHtml.replace('entrypoint" ', 'entrypoint" data-original-filename="entrypoint" ');

// <script ... => <script defer ...
indexHtml = indexHtml.replace(/<script /g, '<script defer ');
Expand Down Expand Up @@ -72,8 +72,8 @@ appScenarios
'has data-original-filename vendor.js'
);
expectFile('./index.html').matches(
'" data-original-filename="app-template.js" type="module">',
'has data-original-filename app-template.js'
'" data-original-filename="entrypoint" type="module">',
'has data-original-filename entrypoint'
);
});
});
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 @@ -17,7 +17,7 @@
{{content-for "body"}}

<script src="/@embroider/core/vendor.js"></script>
<script src="{{rootURL}}assets/ts-app-template.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>

{{content-for "body-footer"}}
</body>
Expand Down
2 changes: 1 addition & 1 deletion tests/ts-app-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="{{rootURL}}assets/ts-app-template.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-footer"}}
Expand Down

0 comments on commit 14b84ff

Please sign in to comment.