This is part of a larger task.
In this first step I just want to export something as a default export from a standard angular app bundle so that later it can be imported using dynamic import using the import expression.
This is what I have so far and it doesn't work. This is the only modification I made to a standard angular app created with ng new
.
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
console.log('I got here');
export class Anything {
pleaseWork() : void {
console.log('please work FFS');
}
}
let a = new Anything();
a.pleaseWork();
export default Anything;
I'm loading the bundle in an empty index.html I have to use it this way.
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<script type="module">
import('/main.js')
.then(module => {
debugger;
console.log(module.default); // <-- i want module.default to not be undefined instead of being undefined
})
.catch(error => { console.error(error); })
</script>
</body>
</html>