https://github.com/imcuttle/babel-plugin-tiny-import
split import from wrap package
https://github.com/imcuttle/babel-plugin-tiny-import
Last synced: 4 months ago
JSON representation
split import from wrap package
- Host: GitHub
- URL: https://github.com/imcuttle/babel-plugin-tiny-import
- Owner: imcuttle
- License: mit
- Created: 2017-10-22T11:48:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-06T06:34:29.000Z (over 2 years ago)
- Last Synced: 2025-08-04T16:03:50.920Z (11 months ago)
- Language: JavaScript
- Size: 238 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# babel-plugin-tiny-import
## Feature
- wrap.js
```javascript
export {default as Tool, toolFunction as outerToolFunction} from 'lib/tool';
export * from 'lib/utils';
export {resolve as rlv} from 'lib/path';
exports.join = require('lib/path/join');
module.exports.join = require('lib/path/extname');
module.exports.extname = require('lib/path-2/extname');
export {default as default} from 'index/join';
```
Input:
```javascript
import {rlv, join as Join} from 'wrap'
const {outerToolFunction: $outerToolFunction} = require('wrap')
```
Output:
```javascript
import { resolve as rlv } from "lib/path";
import Join from "lib/path/extname";
const $outerToolFunction = require("lib/tool").toolFunction;
```
## Options
```text
{
test: /^wrap$/, // RegExp | Function | String
moduleMapper: {} // {} | string | (imported, moduleName) => moduleName | {moduleName: string, ref: string},
easyModuleMapper: {
// `true` means that opt.moduleMapper will be regarded as filename
enable: true,
// watch the opt.moduleMapper file's change.
watch: true,
// the basename of opt.moduleMapper file's *Relative Module*.
basename: false, // true | false | string
resolvePackageAsAbsolute, // boolean | https://www.npmjs.com/package/resolve options, false by default
},
}
```
## Note!!!
the syntax of `require` is not supported yet, which are as follow.
- wrap.js
```javascript
exports.supported = require('lib/total/support');
// MemberExpression
exports.notSupported = require('lib/total').notSupported;
```
- Input
```javascript
// MemberExpression
const notSupported = require('wrap').supported;
const {notSupported: alsoNotSupported} = require('wrap');
let {supported} = require('@befe/wrap');
```
- Output
```javascript
const notSupported = require('wrap').supported;
const {notSupported: alsoNotSupported} = require('wrap');
let supported = require('lib/total/support');
```