Skip to content

Commit

Permalink
Remove typeScriptProxyFileWithImportEqualsRequireAndExportEquals expe…
Browse files Browse the repository at this point in the history
…rimental flag (#512)
  • Loading branch information
emmatown committed Jan 6, 2023
1 parent 46be77a commit 09784cd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 54 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-horses-worry.md
@@ -0,0 +1,5 @@
---
"@preconstruct/cli": patch
---

Removed `typeScriptProxyFileWithImportEqualsRequireAndExportEquals` experimental flag.
5 changes: 0 additions & 5 deletions packages/cli/README.md
Expand Up @@ -47,8 +47,3 @@ There are a number of tasks that become easier with preconstruct that lie slight
- [Kye Hohenberger](https://github.com/tkh44) for thinking of the name preconstruct
- Too many awesome people to name at [Thinkmill](https://thinkmill.com.au) who have given so much great feedback to make Preconstruct better and Thinkmill for sponsoring the development of Preconstruct 💝
- all the people who wrote all the dependencies for this project!

# Things that review would be good on

- https://medium.com/@mitchell_hamilton/introducing-preconstruct-26996f23de2a
-
25 changes: 0 additions & 25 deletions packages/cli/src/__tests__/dev.ts
Expand Up @@ -282,31 +282,6 @@ test("typescript", async () => {
).toMatchSnapshot();
});

test("typescript with typeScriptProxyFileWithImportEqualsRequireAndExportEquals", async () => {
let tmpPath = await testdir({
...typescriptFixture,
"package.json": JSON.stringify({
...JSON.parse(typescriptFixture["package.json"]),
preconstruct: {
___experimentalFlags_WILL_CHANGE_IN_PATCH: {
typeScriptProxyFileWithImportEqualsRequireAndExportEquals: true,
},
},
}),
});

await dev(tmpPath);

await expect(
fs.readFile(path.join(tmpPath, "dist", "typescript.cjs.d.ts"), "utf8")
).resolves.toMatchInlineSnapshot(`
"import mod = require("../src/index");
export = mod;
"
`);
});

test("exports field with worker condition", async () => {
let tmpPath = realFs.realpathSync.native(
await testdir({
Expand Down
36 changes: 15 additions & 21 deletions packages/cli/src/dev.ts
Expand Up @@ -93,18 +93,12 @@ export async function writeDevTSFile(
.join(entrypoint.directory, validFieldsForEntrypoint.main(entrypoint))
.replace(/\.js$/, ".d.ts");

let output = await (entrypoint.package.project.experimentalFlags
.typeScriptProxyFileWithImportEqualsRequireAndExportEquals
? `import mod = require(${JSON.stringify(
normalizePath(
path
.relative(path.dirname(cjsDistPath), entrypoint.source)
.replace(/\.tsx?$/, "")
)
)});\n\nexport = mod;\n`
: entrypointHasDefaultExport(entrypoint, entrypointSourceContent).then(
(hasDefaultExport) =>
`// are you seeing an error that a default export doesn't exist but your source file has a default export?
let output = await entrypointHasDefaultExport(
entrypoint,
entrypointSourceContent
).then(
(hasDefaultExport) =>
`// are you seeing an error that a default export doesn't exist but your source file has a default export?
// you should run \`yarn\` or \`yarn preconstruct dev\` if preconstruct dev isn't in your postinstall hook
// curious why you need to?
Expand All @@ -115,15 +109,15 @@ export async function writeDevTSFile(
// to check for a default export and re-export it if it exists
// it's not ideal, but it works pretty well ¯\\_(ツ)_/¯
` +
tsTemplate(
hasDefaultExport,
normalizePath(
path
.relative(path.dirname(cjsDistPath), entrypoint.source)
.replace(/\.tsx?$/, "")
)
)
));
tsTemplate(
hasDefaultExport,
normalizePath(
path
.relative(path.dirname(cjsDistPath), entrypoint.source)
.replace(/\.tsx?$/, "")
)
)
);

await fs.outputFile(cjsDistPath, output);
}
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/project.ts
Expand Up @@ -28,7 +28,6 @@ export class Project extends Item<{
exports?: JSONValue;
___experimentalFlags_WILL_CHANGE_IN_PATCH: {
logCompiledFiles?: JSONValue;
typeScriptProxyFileWithImportEqualsRequireAndExportEquals?: JSONValue;
keepDynamicImportAsDynamicImportInCommonJS?: JSONValue;
};
};
Expand All @@ -38,7 +37,6 @@ export class Project extends Item<{
this.json.preconstruct.___experimentalFlags_WILL_CHANGE_IN_PATCH || {};
return {
logCompiledFiles: !!config.logCompiledFiles,
typeScriptProxyFileWithImportEqualsRequireAndExportEquals: !!config.typeScriptProxyFileWithImportEqualsRequireAndExportEquals,
keepDynamicImportAsDynamicImportInCommonJS: !!config.keepDynamicImportAsDynamicImportInCommonJS,
};
}
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/validate.ts
Expand Up @@ -130,7 +130,6 @@ export const FORMER_FLAGS_THAT_ARE_ENABLED_NOW = new Set<string>([

export const EXPERIMENTAL_FLAGS = new Set([
"logCompiledFiles",
"typeScriptProxyFileWithImportEqualsRequireAndExportEquals",
"keepDynamicImportAsDynamicImportInCommonJS",
]);

Expand Down

0 comments on commit 09784cd

Please sign in to comment.