1

Sorry for the super newbie vague question, but can I do

import {Component} from 'react'

class MyComponent extends Component { ..

rather than

import * as React from 'react` 

class MyComponent extends React.Component { ..

in babel/webpack/typescript/react ish environment?

If not, why's that?

My webpack.config.json is looking like this.

module: {
  rules: [
    {
      test: /\.js$/,
      use: ['babel-loader', 'source-map-loader'],
      exclude: /node_modules/
    },
    {
      test: /\.tsx?$/,
      exclude: /node_modules/,
      loader: 'happypack/loader?id=ts'
    },

...

plugins: [
  new HappyPack({
    id: 'ts',
    threads: 2,
    loaders: [
      {
        path: 'ts-loader',
        query: { happyPackMode: true }
      }
    ]
  }),

...
4

0 回答 0