Home  >  Q&A  >  body text

javascript - ES6 Module can directly import commonJS modules. Is this implemented directly in ES6, or is it implemented when converting to Babel?

A package written in CommonJS specification, you can use it directly

import connect from 'connect'

Such a syntax introduction is implemented by ES6 Module or only implemented by Babel during translation

習慣沉默習慣沉默2686 days ago889

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-07-05 10:43:50

    CommonJs modules must comply with the Commonjs specification, which is similar to the ES6 syntax, but is not equivalent to the ES6 specification.
    import connect from 'connect' This is written in ES6 syntax. Currently, many browsers do not support ES6 syntax, so a converter is needed, such as Babel, which can convert ES6 syntax statements into ES5 and other syntax statements.

    reply
    0
  • Cancelreply