Skip to content

Commit

Permalink
add new app.js structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Jun 27, 2024
1 parent 348b946 commit bf2c5fe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
9 changes: 7 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ export default [
languageOptions: { sourceType: 'commonjs' },
},
{
files: ['files/app/**/*.js'],
languageOptions: { sourceType: 'module' },
files: ['files/app/**/*.js', 'files-override/app/**/*.js'],
languageOptions: {
sourceType: 'module',
globals: {
...globals.browser,
},
},
},
{ languageOptions: { globals: globals.node } },
pluginJs.configs.recommended,
Expand Down
21 changes: 21 additions & 0 deletions files-override/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Application from '@ember/application';
import compatModules from '@embroider/core/entrypoint';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

let d = window.define;

for (const [name, module] of Object.entries(compatModules)) {
d(name, function () {
return module;
});
}

export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);
7 changes: 6 additions & 1 deletion files-override/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
{{content-for "body"}}

<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script type="module">
import Application from './app';
import environment from './config/environment';

Application.create(environment.APP);
</script>

{{content-for "body-footer"}}
</body>
Expand Down

0 comments on commit bf2c5fe

Please sign in to comment.