fix estree plugin type declaration (#15018)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
1 parent
e2f4ce38f7
commit
7543021ba6
2 files changed
+7
-4
No files matched your search
@@ -0,0 +1,3 @@
|
||||
#### Fix plugins/estree.d.ts to make it a module (#15018 by @kingyue737)
|
||||
|
||||
Add `export {}` in `plugins/estree.d.ts` to fix the "File is not a module" error
|
||||
@@ -38,10 +38,10 @@ async function buildPluginTypes({ file: { input, output } }) {
|
||||
const parserNames = Object.keys(plugin.parsers ?? {});
|
||||
|
||||
// We only add `parsers` to types file, printers should not be used alone
|
||||
// For `estree` plugin, we just write an empty file
|
||||
// For `estree` plugin, we just export an empty object to ensure it treated as a module
|
||||
const code =
|
||||
parserNames.length === 0
|
||||
? ""
|
||||
? "export {};"
|
||||
: outdent`
|
||||
import { Parser } from "../index.js";
|
||||
|
||||
@@ -52,10 +52,10 @@ async function buildPluginTypes({ file: { input, output } }) {
|
||||
`${" ".repeat(2)}${toPropertyKey(parserName)}: Parser;`,
|
||||
)
|
||||
.join("\n")}
|
||||
};\n
|
||||
};
|
||||
`;
|
||||
|
||||
await writeFile(path.join(DIST_DIR, output.file), code);
|
||||
await writeFile(path.join(DIST_DIR, output.file), `${code}\n`);
|
||||
}
|
||||
|
||||
function buildTypes(options) {
|
||||
|
||||
Reference in new issue
Block a user