-
-
Notifications
You must be signed in to change notification settings - Fork 205
adds ability to export module as es6 deafult export #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Current coverage is 96.66% (diff: 100%)@@ master #97 diff @@
==========================================
Files 2 2
Lines 89 90 +1
Methods 11 11
Messages 0 0
Branches 15 16 +1
==========================================
+ Hits 86 87 +1
Misses 3 3
Partials 0 0
|
|
Doesn't look correct to me. Shouldn't it be |
|
I read it as |
|
What about to add |
|
what you think @hemanth? |
|
SGTM for now. |
|
@laland will this pull request fix this issue asked on stack overflow regarding html templates used to beloaded with require syntax? |
|
yep it will, but you should replace require with import. So this example: export class MyComponent implements ng.IComponentOptions {
public template: string = require('./mytempalte.html');
public controller = MyControllerClass;
}...should be tweaked this way: import template from './mytempalte.html';
export class MyComponent implements ng.IComponentOptions {
public template: string = template;
public controller = MyControllerClass;
}and config soulbe like this: //...
module: {
loaders: [
{test: /\.html$/, loader: 'html-loader?exportAsEs6Default'},
//...
]
},and beware of merging of #99 which may alter some behaviour |
|
Thanks @laland . Is it possible to try this right now somehow? |
|
it's already merged, just try. |
|
how to target the merged branch instead v0.4.4. |
|
oh, snap... yes, it's not yet released... try to use giturl instead of version: // package.json
devDependecies: {
"html-loader": "git@github.com:webpack/html-loader.git"
}here's some docs about it: https://docs.npmjs.com/files/package.json#git-urls-as-dependencies |
|
I'm trying to get this new import html syntax to work with typescript but I'm not getting anywhere. I'm sure is something silly and I don't want to create an issue for it if it can be fixed easily. I'm trying: import template from './mytempalte.html';and I'm getting:
// package.json
devDependecies: {
"html-loader": "git@github.com:webpack/html-loader.git",
"ts-loader": "^1.2.2",
}// webpack.config.js
module: {
loaders: [
{test: /\.tsx?$/, loader: "ts-loader"},
{test: /\.html$/, loader: 'html-loader?exportAsEs6Default'},
//...
]
},Update: Found the solutionI added this to my custom typings: // ...
declare module "*.html";
// ... |
|
@callistino Thanks for your update, this solved the problem And generally I want to mention something. If you're using {
"compilerOptions": {
...,
"target": "es5",
...
}
}You have to use {
test: /\.html$/,
loader: 'html?exportAsDefault'
}So use |
|
You can target es5 but set |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
What is the current behavior?
currently html is exported via
module.exportsWhat is the new behavior?
adds ability to export html as es6 default export (via
exports.default) whenexportAsEs6Defaultconfig param is setDoes this PR introduce a breaking change?