bem / webpack-bem-loader

Webpack BEM loader
Other
25 stars 14 forks source link

TypeScript support #59

Open awinogradov opened 6 years ago

awinogradov commented 6 years ago

Now it works only by this way:

import * as Search from 'b:Search';

console.log(Search);

Because we transpile it to:

const Search = ((
(__webpack_require__(2).default || __webpack_require__(2)).applyDecls()
));

// ts use it like this
console.log(Search);

But! If we want use default export only:

import Search from 'b:Search';

console.log(Search);
const Search = ((
(__webpack_require__(2).default || __webpack_require__(2)).applyDecls()
));

// ts use it like this
console.log(Search.default); // .default -> undefined

We need to transpile it like this:

const Search = {
  default: ((
    (__webpack_require__(2).default || __webpack_require__(2)).applyDecls()
  ))
};
qfox commented 6 years ago

Lisp (no):

const Search = {
  default: ((
    ( (x=>(x.default||x))(__webpack_require__(2)) ).applyDecls()
  ))
};
veged commented 6 years ago

@zxqfox what?

Yeti-or commented 6 years ago

we don't work with import we work with require

qfox commented 6 years ago

IT DOES WORK!!!

Guys, why not to use:

declare module 'b:button m:type:radio' {
  etc.
}