extract-css icon indicating copy to clipboard operation
extract-css copied to clipboard

not working in the react and ts.

Open nianxiongdi opened this issue 5 years ago • 1 comments

Steps to reproduce

  • https://codesandbox.io/s/small-leftpad-xh6om

nianxiongdi avatar Sep 03 '19 03:09 nianxiongdi

This is a CommonJS module so it has to be imported with require('../'). It won't work trying to import it as an ES6 module. Webpack supports CommonJS, but for some reason your webpack config says it can't find it. TypeScript supports CommonJS as well but for some reason, I get the same error as trying to import it as an ES6 module.

https://webpack.js.org/concepts/modules/

However, when I use the import extractCSS = require('extract-css');, I get a message saying the babel config doesn't support it. That makes more sense to me.

https://www.typescriptlang.org/docs/handbook/modules.html

My guess is it doesn't work because you are using TypeScript, but I think for it to work with TypeScript, you need to use the TS compiler, not babel. Unless, it's just missing some other config.

jonkemp avatar Sep 03 '19 20:09 jonkemp