A
A
Andrey2017-06-04 12:54:31
JavaScript
Andrey, 2017-06-04 12:54:31

Why doesn't babel convert ES6 in one of the modules?

I use this module in the project, I load it via npm.
I connect like this: const striptags = require('striptags') or like this: import striptags from 'striptags';
Contents of the .babelrc project:

{
  "presets": ["es2015", "stage-0", "react"]
}

As a result, in the assembly I see the following lines:
const STATE_PLAINTEXT = Symbol('plaintext');
    const STATE_HTML      = Symbol('html');
    const STATE_COMMENT   = Symbol('comment');
...

That is, ES6 is not processed by babel.
If you copy the script to the project and include it like this:
import striptags from './../utilities/striptags';
Then everything is OK, in the assembly the above lines already look like this:
var STATE_PLAINTEXT = Symbol('plaintext');
    var STATE_HTML = Symbol('html');
    var STATE_COMMENT = Symbol('comment');
...

If you connect directly from node_modules (import striptags from './../../node_modules/striptags/src/striptags';),
then again the conversion does not work.
This only applies to one module. What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
furrya_black, 2017-06-04
@f-end

Babel will not transpiler node_modules unless it is told to do so in the webpack conf, a
Ups: I'll get to my computer and check your npm module.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question