How to import .html fragment using es6 syntax in TypeScript

rgripper

How to import an HTML template from a relative path like this:

import customSelectHtml from "./custom-select.html!text";

TypeScript compiler complains that it cannot find module. I was trying to create an ambient module definition, but it doesn't allow relative paths in module names. I am using SystemJS as a module loader.

Amid

It is impossible.

Due to the definition of what is module in typescript, and as far as I know in ES6 javascript (import). Module cannot be html. The common approach is to import a javascript module that exports a string containing html, css, whatever. But that is not importing of the file with raw html.

Maybe you want to have a look at html imports also, but that is completely different thing.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

In typescript, how can I import a plain javascript file with a default export using es6 syntax?

how to use node module with es6 import syntax in typescript

How to import class using ES6 syntax? (without Babel)

How to import jquery using ES6 syntax?

How to import pg-promise using ES6 syntax?

linq javascript library with typescript es6 import syntax

How to import Firebase Firestore into a create-react-app project using ES6 syntax

Dynamically import JavaScript module using ES6 syntax?

Converting jsx with ES6 import syntax using reactify

In the `import` syntax of ES6, how is a module evaluated exactly?

How will browsers handle ES6 import/export syntax

How to understand syntax of this TypeScript/ES6 function?

How to understand syntax of this TypeScript/ES6 function?

How to import Vanilla JS ES6 modules in TypeScript?

TypeScript: How to import an ES6 JavaScript class?

How do I import extensions to an ES6/Typescript module

How to alias a prototype function using es6 syntax

ES6 - how to test Jasime tests thru karma using ES6 like 'import' statement

How to import jQuery from a file using es6

How to import and export components using React + ES6 + webpack?

How to import everything from a module in react using es6?

Correct syntax to import constants in ES6

How to write a es6 onchange method using typescript and react?

How to set type dynamically in typescript using 'es6' style?

Import multiple components in vue using ES6 syntax doesn't work

How to import in ES6?

How much Typescript is syntax wise different than es6 / es7

ES6 Style Import in Typescript

How to setup node environment to run ES6 codes involving syntax like `import ... from ...`?