Bamieh
Bamieh

Reputation: 10906

babel does not inject relative requires into the output

I run babel against my source files, i want to output one single file, with all the relative imports injected inside the file.

Source structure

src
│   index.js
│   relative-file.js    
│
└───some-folder
        another-relative-file.js

the index file requires relative-file, and the relative-file requires another-relative-file.

Expected output

index.js with no relative requires, everything is injected inside this one file.

Actual output

index.js with require('./relative-file') inside.

Tried babel-cli commands

babel src --out-file distribution/index.js

output a dir will put output multiple files requiring each other just like the source.

babel src --out-dir distribution

Upvotes: 0

Views: 88

Answers (1)

woryzower
woryzower

Reputation: 976

I don't think babel helps with eliminating requires. You need to use a bundler like webpack in combination with babel to achieve what you want.

Upvotes: 1

Related Questions