WearyMonkey / ngtemplate-loader

Include AngularJS templates in the Webpack bundle and preload the template cache.
MIT License
238 stars 79 forks source link

Cannot use ES6 modules and TypeScript #63

Open eekboom opened 7 years ago

eekboom commented 7 years ago

I have tried a lot of different configuration settings to be able to load my templates like so:

import myTemplateUrl from './hello-angular2-template.thtml';
angular
    .module('pd')
    .component('helloAngular2', {
        templateUrl: myTemplateUrl,
    });

However either all I get from the template import is either "undefined" or an error:

    ERROR in ./src/components/hello-angular2/hello-angular2-template.thtml
    Module parse failed: /home/sfriedrich/dev/ng-webpack/node_modules/ngtemplate-loader/index.js!/home/sfriedrich/dev/ng-webpack/node_modules/html-loader/index.js??ref--0-1!/home/sfriedrich/dev/ng-webpack/src/components/hello-angular2/hello-angular2-template.thtml Unexpected token (2:11)
    You may need an appropriate loader to handle this file type.
    | var path = '/home/sfriedrich/dev/ng-webpack/src/components/hello-angular2/hello-angular2-template.thtml';
    | var html = export default "<div>Angular, from templateURL!</div>";;
    | window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
    | module.exports = path;
     @ ./src/components/hello-angular2/hello-angular2-component.ts 5:38-80
     @ ./src/index.ts
     @ multi (webpack)-dev-server/client?http://localhost:8375 ./src/index.ts

See example project at https://github.com/eekboom/ng-webpack (and also the stackoverflow question at https://stackoverflow.com/questions/44889493/ ).

mribichich commented 7 years ago

is there any news about this? thanks

mikila85 commented 6 years ago

+1

lamuertepeluda commented 4 years ago

Got it compiling with https://stackoverflow.com/questions/44889493/how-to-get-ngtemplate-loader-working-with-webpack-3-angular-1-typescript-and-e/46448698#46448698 (both answer and comment)