1
웹 구성 요소를로드하려면 webpack
을 설정해야합니다. 문제는 typescript
도 사용하고 싶다는 것입니다. 지금까지 내가 찾은 유일한 해결책은 web-components-loader입니다. babel
을 사용하여 es6의 코드를 번역 할 수있는 것 같습니다. typescript
과 유사한 가능성이 있습니까?typescript에 'babel.transform(). code'와 유사한 기능이 있습니까?
import * as ts from "typescript";
let compiledSource = ts.transpile("let x: string = 'string'", {
target: ts.ScriptTarget.ES2015
});
이 the documentation on how to use the compiler API를 참조하십시오
webComponentsLoader: {
transformJs: rawCode => {
return babel.transform(rawCode, {
presets: ['es2015']
}).code;
}
}
답변 해 주셔서 감사합니다. 불행히도 나는 그것을 사용할 수 없었다. 로더가 webpack2와 호환되지 않는 것 같습니다. 결국 나는'app = new App();'과'ts-loader'를 사용하여 웹 컴포넌트의 실행을 시작했다. 그것은 효과가 있었다. –