I am attempting to utilize babel standalone within a react application to transpile Angular TypeScript. The transpiling process seems to be successful, however, I encounter an error when trying to import a component and use its selector within the template of another component.
The error message that is displayed:
Uncaught Error: Template parse errors:
'search-bar' is not a known element:
1. If 'search-bar' is an Angular component, then verify that it is part of this module.
2. If 'search-bar' is a Web Component, then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
SearchBar Component (user code):
// ng is located on the window object
const { Component, NgModule, Output, EventEmitter } = ng.core;
const { CommonModule } = ng.common;
@Component({
selector: 'search-bar',
template: `<div>Search Bar</div>`,
})
@NgModule({
declarations: [SearchBar],
exports: [SearchBar]
})
class SearchBar {}
export default SearchBar;
App Component (user code):
const { Component, NgModule, VERSION } = ng.core;
const { CommonModule } = ng.common;
// Note: The online editor does not require a path to the component :)
import SearchBar from 'SearchBar.ts';
@NgModule({
imports: [
CommonModule,
SearchBar,
],
declarations: [AppComponent, SearchBar],
})
@Component({
selector: 'my-app',
template: `<search-bar></search-bar>`
})
export default class AppComponent {
}
It is essential to mention that I am developing an online code editor which necessitates the usage of babel standalone. Below is my babel configuration for typescript:
(extracted from my react app)
const TS_OPTIONS = {
presets: [
['typescript', { allExtensions: true }],
['es2017', { 'modules': false }],
],
plugins: [
["proposal-decorators", { "legacy": true }],
["proposal-class-properties", { "loose" : true }],
'transform-modules-commonjs',
],
};
Babel version being utilized:
https://unpkg.com/@babel/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="added9ccc3c9ccc1c2c3c8ed9a839c9f8394">[email protected]</a>/babel.min.js
My simplified transpile function (also extracted from my react app):
export default function transpile(myCode) {
const { code } = Babel.transform(myCode, TS_OPTIONS);
return myCode;
}
What could I possibly be overlooking?