-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(next-drupal): rearrange files into multiple entry points
Fixes #442
- Loading branch information
Showing
30 changed files
with
1,806 additions
and
1,668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { readdir, copyFile } from "node:fs/promises" | ||
|
||
const files = await readdir("./dist") | ||
for (const file of files) { | ||
if (file.endsWith(".modern.js")) { | ||
const base = file.replace(/\.modern\.js$/, "") | ||
|
||
// Make a duplicate of the type definitions. | ||
// | ||
// From the TypeScript docs: | ||
// | ||
// "It’s important to note that the CommonJS entrypoint and the ES module | ||
// entrypoint each needs its own declaration file, even if the contents are | ||
// the same between them." | ||
// | ||
// @see https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing | ||
await copyFile(`./dist/${base}.d.ts`, `./dist/${base}.cjs.d.ts`) | ||
} | ||
} | ||
console.log(`Created unique *.d.ts files for CommonJS build.`) |
Oops, something went wrong.