javascript - Duplicated declarations in compiled out-file using Babel -


i trying compile 2 es6 files single es5 output file using babel. resulting file seems contain duplicated declarations like:

var _createclass = function () { ... } 

and

object.defineproperty(exports, '__esmodule', {value: true}); 

here files:

file1 (./ec6/ec6class.js)

export class myclass {     constructor(dep1, dep2) {      }      foo() {         console.log('foo')     } } 

file 2 (./ec6/ec6class2.js)

import myclass './ec6class';  export class myclass2 extends myclass {     constructor(dep1, dep2) {         super(dep1, dep2)     }      bar() {         console.log('bar')     } } 

my babel cli command is:

babel src/client/ec6 --out-file script-compiled.js 

how compile 2 file single file single declarations of babel infrastructure? having duplicated declarations not desired behaviour.

i think problem telling babel compile files finds in src/client/ec6, while want single point of entry (in fact, have that). babel compile ec6class.js once because it's file in directory, , second time because it's imported in ec6class2.js.

try with

babel src/client/ec6/ec6class2.js --out-file script-compiled.js

edit
sorry answered fast. in fact, babel meant transpile javascript file cutting edge version of es more compatible one. need combine webpack, tool "packs" multiple javascript files 1 (it can minify them well).

you can use webpack command line , tell use babel transpile files first. getting started guide can read webpack — the confusing parts on medium.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -