I am developing two node packages registered with npm and using es6 syntax. Each package has only one es6 module exporting one class.
- the package
Ahas no dependencies - package
Bdepends onA
Class A
export default class A {...}
Class B
import A from 'A'
export default class B {...}
Each package has the following structure
modules/
index.js (es6 source)
index.js (commonjs source)
- The source code is in
es6/index.js - It translates to es5 / commonjs using Babel
Question
I want to give users of my packages A and B the choice to use es6 (by importing class B, which itself will import A es6 class, not es5 A) or es5 sources (requiring the es5 B function, which itself requires the es5 A function): What the best way to achieve it?
source
share