Skip to content

Commit

Permalink
feat: add wildcard plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dword-design committed Sep 10, 2020
1 parent 5f5c92a commit 57c4f3f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-transform-imports": "^2.0.0",
"babel-plugin-wildcard": "dword-design/babel-plugin-wildcard#fork",
"find-up": "^5.0.0",
"get-package-name": "^1.0.0",
"param-case": "^3.0.3"
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default {
},
},
],
[getPackageName(require.resolve('babel-plugin-wildcard')), { exts: [] }],
],
presets: [
[
Expand Down
32 changes: 24 additions & 8 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
'foo.js': 'export default 1',
'index.js': endent`
import foo from '@/foo'
export default foo
`,
'package.json': JSON.stringify({}),
Expand All @@ -44,7 +44,7 @@ export default {
'foo.js': 'export default 1',
'index.js': endent`
import foo from '@/foo'
export default foo
`,
},
Expand All @@ -59,7 +59,7 @@ export default {
'foo.js': 'export default 1',
'index.js': endent`
import foo from '@/sub/src/foo'
export default foo
`,
},
Expand All @@ -72,7 +72,7 @@ export default {
'bar/index.js': 'export default 1',
'foo/index.js': endent`
import bar from '@/src/bar'
export default bar
`,
},
Expand All @@ -88,6 +88,22 @@ export default {
},
test: () => expect(require(resolve('dist'))).toBeTruthy(),
},
'import: directory': {
files: {
src: {
foo: {
'bar.js': 'export default 1',
'baz.js': 'export default 2',
},
'index.js': endent`
import * as foo from './foo'
export default foo
`,
},
},
test: () => expect(require(resolve('dist'))).toEqual({ Bar: 1, Baz: 2 }),
},
'jsx: functional: context': {
files: {
'src/index.js': endent`
Expand All @@ -104,7 +120,7 @@ export default {
expect(await readFile(resolve('dist', 'index.js'), 'utf8'))
.toEqual(endent`
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Expand Down Expand Up @@ -133,7 +149,7 @@ export default {
expect(await readFile(resolve('dist', 'index.js'), 'utf8'))
.toEqual(endent`
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Expand All @@ -160,7 +176,7 @@ export default {
expect(await readFile(resolve('dist', 'index.js'), 'utf8'))
.toEqual(endent`
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Expand All @@ -170,7 +186,7 @@ export default {
const h = arguments[0];
return h("div", ["Hello world"]);
}
};
exports.default = _default;
module.exports = exports.default;
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,12 @@ babel-plugin-transform-imports@^2.0.0:
"@babel/types" "^7.4"
is-valid-path "^0.1.1"

babel-plugin-wildcard@dword-design/babel-plugin-wildcard#fork:
version "6.0.0"
resolved "https://codeload.github.com/dword-design/babel-plugin-wildcard/tar.gz/c5ed97308da37a98dfa7df56bf7e20b9c7ea999d"
dependencies:
rimraf "^2.6.2"

bail@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.5.tgz#b6fa133404a392cbc1f8c4bf63f5953351e7a776"
Expand Down

0 comments on commit 57c4f3f

Please sign in to comment.