Skip to content

Commit 11ad3be

Browse files
committed
fix(init): use correct prefix for exports, imports, and tsc paths
1 parent 94e1099 commit 11ad3be

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bin/jswt-init.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ async function main() {
9595
jsconfig = await createJsConfig(
9696
pkg,
9797
tsconfigTxt,
98+
prefix,
9899
`${prefix}/${pkgName}.js`,
99100
);
100101
}
@@ -318,7 +319,7 @@ async function main() {
318319
"set",
319320
"type=module",
320321
`exports[.]=${mainPath}`,
321-
`exports[./*]=./*`,
322+
`exports[./*]=${prefix}/*`,
322323
];
323324
await exec("npm", allArgs);
324325
await sortAndWritePackageJson();
@@ -334,6 +335,7 @@ async function main() {
334335
"set",
335336
"type=module",
336337
`imports[${pkg.name}]=${mainPath}`,
338+
`imports[${pkg.name}/]=${prefix}/`,
337339
];
338340
await exec("npm", allArgs);
339341
await sortAndWritePackageJson();
@@ -345,7 +347,7 @@ async function main() {
345347
` {`,
346348
` "imports": {`,
347349
` "${pkg.name}": "${mainPath}",`,
348-
` "${pkg.name}/": "./"`,
350+
` "${pkg.name}/": "${prefix}/"`,
349351
` }`,
350352
` }`,
351353
`</script>`,
@@ -628,10 +630,11 @@ async function getLatest20xx() {
628630
* @param {Object} pkg
629631
* @param {String} pkg.name
630632
* @param {String} tsconfigTxt
633+
* @param {String} prefix
631634
* @param {String} mainPath
632635
* @returns
633636
*/
634-
async function createJsConfig(pkg, tsconfigTxt, mainPath) {
637+
async function createJsConfig(pkg, tsconfigTxt, prefix, mainPath) {
635638
if (!tsconfigTxt.includes(`"include":`)) {
636639
let includables = [
637640
"*.js",
@@ -651,7 +654,7 @@ async function createJsConfig(pkg, tsconfigTxt, mainPath) {
651654
{
652655
let lines = [
653656
` "${pkg.name}": ["${mainPath}"]`,
654-
` "${pkg.name}/*": ["./*"]`,
657+
` "${pkg.name}/*": ["${prefix}/*"]`,
655658
];
656659
let str = lines.join(`,\n`);
657660
tsconfigTxt = tsconfigTxt.replace(

0 commit comments

Comments
 (0)