Skip to content

Commit 95a596c

Browse files
committed
🐛 .s.tsの出力結果修正
1 parent b4a5140 commit 95a596c

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

dev/build.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ async function buildRollup() {
122122
});
123123
}
124124

125+
function fixDtsOutputFlexible(filePath) {
126+
let code = fs.readFileSync(filePath, "utf8");
127+
128+
const reg = new RegExp(`export\s{\s${script_name}\sas\sdefault\s};`);
129+
code = code.replace(reg, `export default ${script_name};`);
130+
131+
fs.writeFileSync(filePath, code);
132+
}
133+
125134
(async () => {
126135
const debug = true;
127136
try {
@@ -160,6 +169,9 @@ async function buildRollup() {
160169
console.log(`┃┗✅ ${CL.brightWhite("rollup完了")}: ${getRelativePath(typesPath)}`);
161170
console.log(`┃🗑️ ${CL.brightWhite("types仮フォルダcleanup")}`);
162171
prepareDir(typesTmpDir);
172+
console.log(`┃🌵 ${CL.brightWhite("export問題を解決")}`);
173+
fixDtsOutputFlexible(typesPath);
174+
console.log(`┃┗✅ ${CL.brightWhite("export default 生成完了")}: ${getRelativePath(typesPath)}`);
163175
showFileSize(typesPath);
164176
}
165177

dev/createEntryEndpoint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const fs = require("node:fs");
22
const path = require("node:path");
33

44
function generateEndpoint(entryPath) {
5-
const inData = `import * as lib from "./index.js";
6-
export default lib;
5+
const inData = `import * as JavaLibraryScript from "./index.js";
6+
export default JavaLibraryScript;
77
`;
88
fs.writeFileSync(entryPath, inData, "utf8");
99
}

dev/tempCodeRunnerFile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ce( ${script_name})(\\s*{)`);
2+
// code = code.replace(reg1, "$1const$2:$3");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javalibraryscript",
3-
"version": "v1.0.4.0",
3+
"version": "v1.0.4.1",
44
"description": "Javaの機能をJavaScriptに適当に再現",
55
"main": "index.js",
66
"scripts": {

test/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { default: JavaLibraryScript } = require("../types/JavaLibraryScript");
2+
13
jasc.on("DOMContentLoaded", () => {
24
console.log("JavaLibraryScript");
35
console.log(JavaLibraryScript);
@@ -19,7 +21,7 @@ function main() {
1921
console.log(
2022
map
2123
.stream()
22-
.map(([k, v]) => [k, v * 10])
24+
.map(([k, v]) => [k, "a"])
2325
.toHashMap(String, Number)
2426
);
2527
}

types/JavaLibraryScript.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -950,15 +950,15 @@ declare let util: {
950950
};
951951
};
952952

953-
declare const lib_base: typeof base;
954-
declare const lib_libs: typeof libs;
955-
declare const lib_util: typeof util;
956-
declare namespace lib {
953+
declare const JavaLibraryScript_base: typeof base;
954+
declare const JavaLibraryScript_libs: typeof libs;
955+
declare const JavaLibraryScript_util: typeof util;
956+
declare namespace JavaLibraryScript {
957957
export {
958-
lib_base as base,
959-
lib_libs as libs,
960-
lib_util as util,
958+
JavaLibraryScript_base as base,
959+
JavaLibraryScript_libs as libs,
960+
JavaLibraryScript_util as util,
961961
};
962962
}
963963

964-
export { lib as default };
964+
export default JavaLibraryScript;

0 commit comments

Comments
 (0)