vihanb / babel-plugin-wildcard

Wildcard imports import a directories JS files
MIT License
186 stars 27 forks source link

Can add support for lazy loading? #23

Open Knight704 opened 6 years ago

Knight704 commented 6 years ago

Hi there, wonder if there is config parameter to control lazy loading. For example (from doc) instead of:

const Items = {};
import _wcImport from "./dir/a";
Items.A = _wcImport;

desired result when lazy:

const Items = {};
Object.defineProprty(Items, 'A', {
  get: () => require('./dir/a')
});
vihanb commented 6 years ago

Not yet but definetly I’ll look into in a few weeks. Would be useful with import() as that gains traction

ChuckFields commented 5 years ago

This would be an awesome feature!

vihanb commented 5 years ago

Adding this I'm inclined to support import() instead but I'll consider an option