Created
April 10, 2019 01:43
-
-
Save branflake2267/958438db87bb657df73238a999a8941c to your computer and use it in GitHub Desktop.
Using babel to compile Angular.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<base href="/"> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Sandbox</title> | |
<script src="ext-angular-fiddle-bundle.js"></script> | |
</head> | |
<body> | |
Loaded... | |
<myapp-root></myapp-root> | |
<script> | |
window.require = (mod) => { | |
// Imports are brought in through wepack bundlelibs | |
console.log("require(mod) mod=" + mod); | |
var m = Sencha.bundlelibs[mod]; | |
return m; | |
} | |
// TODO figure ut why I had to do this, commonjs? | |
exports = {}; | |
</script> | |
<!-- No way to provide legacy decorators with inline script. Thus override babel bundle code with: | |
presets: script.presets: | |
['env', {'modules': false} ], | |
plugins: script.plugins: | |
['proposal-decorators', { 'legacy': true }], 'transform-modules-commonjs', | |
--> | |
<script type="text/babel" data-presets="typescript"> | |
// Must be first!!!! | |
// If it's in a webpack bundle, load it first there too! | |
import 'core-js/es7/reflect'; | |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { Component } from '@angular/core'; | |
@Component({ | |
selector: 'myapp-root', | |
template: `<h1> | |
{{title}} | |
Hello World | |
</h1>` | |
}) | |
export class AppComponent { | |
title = 'myapp works!'; | |
} | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule | |
], | |
providers: [], | |
bootstrap: [ | |
AppComponent | |
] | |
}) | |
export class AppModule { } | |
platformBrowserDynamic().bootstrapModule(AppModule); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment