hedgedoc/frontend
Tilman Vatteroth 8e2d59ff3c fix(commons): replace microbundle with bash based compile script
The commons package ships wrong types because it is refering to the same files for the ESM and the CJS build.
See https://arethetypeswrong.github.io/?p=%40mrdrogdrog%2Foptional%401.1.0

This happens because microbundle can handle the generation of `.mjs` and `.cjs` from files itself but delegates the generation of types entirely to typescript by running it once. Microbundle uses the "type" field from the package.json to know if a `.js` file is meant to be mjs or cjs and generates the other type by using the specific file extension `.cjs` and `.mjs` (so if your package is a `type: module`, then `.js` file are interpreted as ECMAModule and if you have a commonjs file you need to name it `.cjs`).  But this causes a problem with typescript. If you use typescript with the newer module resolver then it expects the type declarations to be named exactly like the file you wanna import. So if you have a `.js` file it will try to look up types in a `.d.ts` file. If it is resolving a `.mjs` file it is looking for a `.d.mts` file.

This clashes with the types generated by microbundle because you can't use a `.mjs` file with a `.d.ts` file.

Running typescript multiple times can also be complicated.
When generating type declaration files, typescript takes a look at the source file extension. So a `.mts` file will generate a `.mjs` and a `.d.mts` file. A `.ts` will generate a `.js` and `.d.ts` file. It doesn't matter if you run microbundle on `.ts`, `.mts` or `.cjs` files, it will only generate the type declarations once.

How do you get the other type declaration? To solve this problem you either have to run typescript multiple times and manipulate the input or output data to have correct `.d.mts` / `.d.cts` files AND imports... or do what this PR changes.

It runs typescript multiple times but places the complied files in different directories. It then places a package.json in both directories which declares if `.js` is commonjs or ESM.
This way the resolver is happy because it can import `.js` files according to the package.json content and typescript is happy because it can find type declarations. And because package.json files are inheriting properties from other package.json files no necessary file is missing.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2023-07-30 14:56:29 +02:00
..
.netlify fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
cypress feat(frontend): delete revision 2023-07-24 20:05:10 +02:00
docker chore(deps): update node.js to 49f1c20 2023-07-22 01:09:23 +00:00
global-styles fix: replace dark mode hack with bootstrap's own dark mode 2023-06-04 22:38:50 +02:00
locales feat(frontend): delete revision 2023-07-24 20:05:10 +02:00
netlify fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
public fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
src fix(commons): replace microbundle with bash based compile script 2023-07-30 14:56:29 +02:00
.editorconfig chore: fix and reformat editorconfig 2023-04-24 13:39:33 +02:00
.env fix: add .env file symlinks 2023-04-13 10:39:17 +02:00
.env.test fix(config): Replace HD_DOMAIN and HD_EDITOR_BASE_URL with HD_BASE_URL 2023-02-05 22:32:31 +01:00
.env.test.license fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
.eslintrc.js feat(package): adjust packages to workspaces 2022-12-04 20:59:46 +01:00
.gitignore fix(frontend): remove redundant rules from gitignore 2022-11-20 21:29:17 +01:00
.prettierignore fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
.prettierignore.license fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
.prettierrc.json fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
.prettierrc.json.license fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
CHANGELOG.md feat(frontend): replace forkawesome with bootstrap icons 2023-02-24 14:31:17 +01:00
CONTRIBUTING.md fix(frontend): Remove redundant information from CONTRIBUTING.md 2022-11-20 21:50:10 +01:00
cypress.config.ts fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
jest.config.ts feat(frontend): replace forkawesome with bootstrap icons 2023-02-24 14:31:17 +01:00
netlify.toml fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
next-env.d.ts fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
next-env.d.ts.license fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
next.config.js enhancement: add profiling flag to analyze run 2023-06-27 11:04:27 +02:00
package.json fix(deps): update dependency @hedgedoc/markdown-it-plugins to v2.1.2 2023-07-30 12:13:04 +00:00
package.json.license fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00
tsconfig.json feat(frontend): replace forkawesome with bootstrap icons 2023-02-24 14:31:17 +01:00
tsconfig.json.license fix: Move content into to frontend directory 2022-11-20 19:48:40 +01:00