8e2d59ff3c
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> |
||
---|---|---|
.github | ||
.idea/copyright | ||
.reuse | ||
.yarn | ||
backend | ||
commons | ||
dev-reverse-proxy | ||
docker | ||
docs | ||
frontend | ||
LICENSES | ||
.dockerignore | ||
.env.example | ||
.env.example.license | ||
.gitattributes | ||
.gitignore | ||
.mailmap | ||
.mailmap.license | ||
.nvmrc | ||
.nvmrc.license | ||
.yarnrc.yml | ||
AUTHORS | ||
CODE_OF_CONDUCT.md | ||
codecov.yml | ||
CONTRIBUTING.md | ||
eslint-local-rules.js | ||
LICENSE | ||
package.json | ||
package.json.license | ||
README.md | ||
renovate.json | ||
renovate.json.license | ||
SECURITY.md | ||
turbo.json | ||
turbo.json.license | ||
yarn.lock | ||
yarn.lock.license |
HedgeDoc lets you create real-time collaborative markdown notes.
Getting Started
- ℹ️ Read all about HedgeDoc and the history of the project on our website
- 🧪 Try out HedgeDoc with the demo instance. Check out the features page!
- 💽 Install HedgeDoc yourself using the install guide
- ❓ Questions? Join our Matrix chat or the community forums
- 💬 Stay up to date by subscribing to the release feed
State of the project
HedgeDoc 1.x is stable and used around the world, but the codebase has grown over time,
making it hard to add new features.
We are currently working on HedgeDoc 2, a complete rewrite of HedgeDoc. Please note the following:
- This branch contains the latest development code and does not implement all features yet. If you are looking for the 1.x source code, have a look at the master branch.
- The 1.x release is maintenance-only. We do not accept feature requests or PRs for this release anymore and may choose to close non-critical bug reports, if the bug will be non-existent in 2.0.
- HedgeDoc 2 will be split in two components. The backend and the frontend. Both are present in this repository.
Development
Information for setting up a local development environment can be found in the developer documentation
HedgeDoc 2 UI Test
Curious about the new look and feel of HedgeDoc 2? We provide a demo of the new UI on hedgedoc.dev. This version uses mocked data and has no data persistence.
The UI test is hosted by netlify. Please check their privacy policy as well as ours.
Contributions
We welcome contributions!
Have a look at our contribution docs to find out how you can help. If you want to contribute to
HedgeDoc 2, please join our development chat.
License
Licensed under AGPLv3. For our list of contributors, see AUTHORS.
The license does not include the HedgeDoc logo, whose terms of usage can be found in the github repository.