Skip to content

Commit

Permalink
test: add example wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Feb 11, 2024
1 parent 88a8577 commit 6486547
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/wildcard/lib/components/bar.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function bar(): void;
11 changes: 11 additions & 0 deletions examples/wildcard/lib/components/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });

// src/components/bar.ts
function bar() {
console.log("bar");
}
__name(bar, "bar");
export {
bar
};
1 change: 1 addition & 0 deletions examples/wildcard/lib/components/foo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function foo(): void;
11 changes: 11 additions & 0 deletions examples/wildcard/lib/components/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });

// src/components/foo.ts
function foo() {
console.log("foo");
}
__name(foo, "foo");
export {
foo
};
1 change: 1 addition & 0 deletions examples/wildcard/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function load(name: string): any;
15 changes: 15 additions & 0 deletions examples/wildcard/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });

// src/index.ts
var map = {
foo: () => import("./components/foo.js"),
bar: () => import("./components/bar.js")
};
function load(name) {
return map[name]();
}
__name(load, "load");
export {
load as default
};
19 changes: 19 additions & 0 deletions examples/wildcard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@dunble-examples/wildcard",
"version": "0.0.0",
"private": true,
"type": "module",
"exports": {
".": "./lib/index.js",
"./components/*": "./lib/components/*.js",
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc -b && dunble"
},
"devDependencies": {
"dunble": "^0.1.0",
"esbuild": "^0.19.0",
"typescript": "^5.3.2"
}
}
3 changes: 3 additions & 0 deletions examples/wildcard/src/components/bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function bar() {
console.log('bar')
}
3 changes: 3 additions & 0 deletions examples/wildcard/src/components/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function foo() {
console.log('foo')
}
8 changes: 8 additions & 0 deletions examples/wildcard/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const map = {
foo: () => import('./components/foo.js'),
bar: () => import('./components/bar.js'),
}

export default function load(name: string) {
return map[name]()
}
13 changes: 13 additions & 0 deletions examples/wildcard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"rootDir": "src",
"outDir": "lib",
"target": "esnext",
"module": "nodenext",
"declaration": true,
"emitDeclarationOnly": true,
},
"include": [
"src",
],
}

0 comments on commit 6486547

Please sign in to comment.