PR: TypeScript has no .mjs .cjs support out of the box
TypeScript has no .mjs .cjs support out of the box i have a patched version of it but it is a blocking issue since 5+ years and will not get solved soon
to be compatible with ECMAScript modules we need to release a diffrent version of @vertx/* we need to release a CJS and a ESM version both with the same .d.ts files and the extension needs to be .js even for the ECMAScript version. So that there is intelliSense support inside the IDE.
also files like mod.mjs need to be converted to Module style so no extension defined else it will not find the .d.ts files
the current version of @vertx/* only works with require when the module specifier is used and with .mjs we get no types.
Update
We should offer the following formart
Method 1
SubFolder esm needs to contain package,json which references the type and types
// @vertx/**/esm/*.js,*.d.ts // The d.ts should import and reexport @vertx/**/*.d.ts
// Allows import like
import '@vertx/core/esm'
require('@vertx/core/cjs'
Method 2
// @vertx/**/*.mjs.d.ts // The d.ts should import and reexport @vertx/**/*.d.ts
// Allows import like
import '@vertx/core/index.mjs'
require('@vertx/core')
Method 3 most best at present!
Combine 1 and 2 till typescript adopts .mjs .cjs support
at present it is not possible to use vertx inside the ESM context with correct types inside the IDE
Reproduce
import { FileSystem } from '@vertx/core'
// Will throw as it loads the CJS version.
// import { FileSystem } from '@vertx/core/index.mjs' would not throw but would have no types added we would need to add index.mjs.d.ts which needs to reexport the content of index.d.ts
es4x init
npm install @vertx/core
# Create index.mjs
es4x install
es4x index.mjs
Will create a PR i have added it to the generators so that method 2 works as this is the less inversive methode
this needs also clean up inside Documentation https://github.com/reactiverse/es4x/blob/develop/docs/get-started/hello-world.md
first line should be to
///
to turn on allowJs or create a jsconfig.json with {} as content
we should list all 3 methods
typescript now got mjs support by the way this needs to get closed @pmlopes