vihanb / babel-plugin-wildcard

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

Not working #24

Closed vinpac closed 6 years ago

vinpac commented 6 years ago

Hello, I cant get it to work Am I doing something wrong?

Source

import db from 'Server/data/sequelize'
import * as mahalo from './*'

delete models.Index

Output

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _sequelize = _interopRequireDefault(require("../sequelize"));

var _index = _interopRequireDefault(require("./index.js"));

var _UserSession = _interopRequireDefault(require("./UserSession.js"));

var _UserProfile = _interopRequireDefault(require("./UserProfile.js"));

var _UserLogin = _interopRequireDefault(require("./UserLogin.js"));

var _User = _interopRequireDefault(require("./User.js"));

var _Post = _interopRequireDefault(require("./Post.js"));

var _ItemImage = _interopRequireDefault(require("./ItemImage.js"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

delete models.Index;

.babelrc

{
  "plugins": [
    "transform-es2015-modules-commonjs",
    ["module-resolver", {
      "alias": {
        "Server": "./src/server",
        "Ducks": "./src/ducks",
        "Lib": "./src/lib",
        "Core": "./src/server/core"
      }
    }],
    "wildcard"
  ],
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": { "node": "6" },
        "modules": false,
        "useBuiltIns": false,
        "debug": false
      }
    ],
    "@babel/preset-stage-2",
    "@babel/preset-react",
    "@babel/preset-flow"
  ]
}

babel 7

vihanb commented 6 years ago

can you share what your project file/folder structure is like? Perhaps try (import * as mahalo from '.' though the way you are doing should work...)

vinpac commented 6 years ago

Worked. Thanks!