inline-import.macro
The Problem
You want use a veriable once inline, but you have to import it at top of the file.
The Solution
This is a babel-plugin-macro which allows you import file inline.
Installation
This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies
:
npm install --save-dev inline-import.macro
Usage
Once you've configured babel-plugin-macro you can import/require inline-import.macro.
Here are a few before/after examples:
import importPage from 'inline-import.macro';
const routes = [
importPage('./aa'),
importPage('./bb'),
importPage('./cc'),
importPage('./dd'),
];
import _dd from "./dd";
import _cc from "./cc";
import _bb from "./bb";
import _aa from "./aa";
const routes = [
_aa,
_bb,
_cc,
_dd]
;