-
Notifications
You must be signed in to change notification settings - Fork 71
Definitions created only match the output when using style-loader and namedExport #5
Comments
Hey @Zalastax thanks for the work! Would you mind to open a pull-request? I checked some of your fixes, I think it would make sense to open several there 😄 . That being said, I am not entirely sure that i get your first issue, what exactly do you mean with the Again thanks for the work! |
[1] function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(2)(); // 2 is css-loader base code
// imports
// module
exports.push([module.id, "._3xa5lyhHp10qoUNQHktGL {\n color: white;\n}\n\n._3FvfrYo1XzOMAEcFNpnMG6 {\n color: green;\n}\n", ""]);
// exports
exports.locals = {
"foo": "_3xa5lyhHp10qoUNQHktGL",
"bar-baz": "_3FvfrYo1XzOMAEcFNpnMG6"
};
} [2] module: {
loaders: [
{ test: /\.ts$/, loaders: ['babel', 'ts'] },
{ test: /example.css$/, loader: 'style!../src/index.js?modules' },
{ test: /example-camelcase.css$/, loader: 'style!../src/index.js?modules&camelCase' },
{ test: /example-namedexport.css$/, loader: 'style!../src/index.js?modules&namedExport' },
{ test: /example-camelcase-namedexport.css$/, loader: 'style!../src/index.js?modules&camelCase&namedExport' }
]
} [3] function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(2); // 2 is our module with css seen above (numbers changed)
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(4)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!./../src/index.js?modules!./example.css", function() {
var newContent = require("!!./../src/index.js?modules!./example.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
} [4] interface IExampleCss {
'foo': string;
'bar-baz': string;
}
export = IExampleCss; |
Hi @Zalastax thanks for the write up! I like your thinking, just one last question, taken from the typescript documentation, would that mean we need to go for |
You are right about |
The final output that the type definitions are supposed to match is very fragile.
E.g.
loaders: ['typings-for-css-modules-loader?sourceMap&modules']
creates an export of the css likewhich is not the exports.default that the definition expect.
loaders: ['style', 'typings-for-css-modules-loader?sourceMap&modules&importLoaders=1'}
creates an export of the css likewhich I expected to be an object on exports.default but instead got the same behaviour as if
namedExport
was defined. See webpack/style-loader#local-scope-css and webpack-contrib/style-loader#77I think changing the export from default to locals is correct and adding to the readme that style-loader requires namedExport. I've made some of those changes and fixed some others in my fork
The text was updated successfully, but these errors were encountered: