@fgiova/cjs-esm-ts-builder 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -98,8 +98,12 @@ const replaceExportImportDeclarations = async (content, sourceFile) => {
|
|
|
98
98
|
content = content.replace(declaration, `"${importModule}.mjs"`);
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
+
const replaceDirname = (content) => {
|
|
102
|
+
return content.replaceAll(/(?<!\))__dirname(?!\()/g, "import.meta.dirname")
|
|
103
|
+
.replaceAll(/(?<!\))__filename(?!\()/g, "import.meta.filename");
|
|
104
|
+
};
|
|
101
105
|
const replaceDeclarations = async (content, sourceFile) => {
|
|
102
|
-
return await replaceInlineImports(await replaceExportImportDeclarations(content, sourceFile), sourceFile);
|
|
106
|
+
return await replaceInlineImports(await replaceExportImportDeclarations(replaceDirname(content), sourceFile), sourceFile);
|
|
103
107
|
};
|
|
104
108
|
const fileIsProcessable = (sourcepath) => {
|
|
105
109
|
const extname = path.extname(sourcepath);
|
|
@@ -62,8 +62,12 @@ const replaceExportImportDeclarations = async (content, sourceFile) => {
|
|
|
62
62
|
content = content.replace(declaration, `"${importModule}.mjs"`);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
+
const replaceDirname = (content) => {
|
|
66
|
+
return content.replaceAll(/(?<!\))__dirname(?!\()/g, "import.meta.dirname")
|
|
67
|
+
.replaceAll(/(?<!\))__filename(?!\()/g, "import.meta.filename");
|
|
68
|
+
};
|
|
65
69
|
const replaceDeclarations = async (content, sourceFile) => {
|
|
66
|
-
return await replaceInlineImports(await replaceExportImportDeclarations(content, sourceFile), sourceFile);
|
|
70
|
+
return await replaceInlineImports(await replaceExportImportDeclarations(replaceDirname(content), sourceFile), sourceFile);
|
|
67
71
|
};
|
|
68
72
|
const fileIsProcessable = (sourcepath) => {
|
|
69
73
|
const extname = path.extname(sourcepath);
|