Skip to content

Breaking: Support ESM only, rename num to number#13

Draft
evelynhathaway wants to merge 2 commits intomainfrom
beta
Draft

Breaking: Support ESM only, rename num to number#13
evelynhathaway wants to merge 2 commits intomainfrom
beta

Conversation

@evelynhathaway
Copy link
Copy Markdown
Owner

No description provided.

evelynhathaway and others added 2 commits May 21, 2021 11:37
## v2.0.0-beta.1

**[`v1.0.6...v2.0.0-beta.1`](v1.0.6...v2.0.0-beta.1)** - **2021-05-21**

### 💥 Breaking

- Support ESM only, rename num to number [`f5ce597`](f5ce597)

### Other

- **dev:** Bump conventional-changelog-evelyn from 1.2.3 to 1.3.0 [`358777c`](358777c)
- **dev:** Bump eslint-plugin-evelyn from 5.0.4 to 5.0.5 [`640ac4b`](640ac4b)
@evelynhathaway
Copy link
Copy Markdown
Owner Author

Before I go ahead and only support native ESModules in future packages, I am using use-back and this MR as a canary. So far, it looks like ESM for Node.js is just not ready.

  • Much of the Node.js ecosystem relies on CommonJS as the backbone of the module ecosystem (so you will have only experimental support in Jest, will still have to use CJS for ESLint, etc.)
    • This will get better with time and is not a big blocker
  • TypeScript doesn't compile to .mjs extensions
    • TypeScript isn't a build tool for ESM, basically
  • TypeScript doesn't compile to native ESM compatible imports (it uses CommonJS node resolutions with the import syntax)
  • There is currently no way to statically enforce using Node.js native ESM compatible imports

"extends": [
"plugin:evelyn/default",
"plugin:evelyn/typescript",
"plugin:evelyn/esm",
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging, this config needs to better enforce best practices with importing to prevent easily making super annoying bugs for users

"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.semicolons": "insert",
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.importModuleSpecifierEnding": "js",
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this to make TypeScript import the ghost .js files when using VSCode

},
moduleNameMapper: {
"(.*)\\.js$": ["$1"],
},
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to tell the @next version of ts-jest and jest to strip off the .js from the imports since they technically didn't exist and ts-jest doesn't resolve the ghosts like the eslint plugin import resolver for TypeScript.

{
"name": "loose-rgb",
"version": "1.0.6",
"type": "module",
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I heard not to use "type": "module", but... I am not adding a plugin just to rename files to .mjs at this point

@@ -1,4 +1,4 @@
import {normalize} from "..";
import {normalize} from "../index.js";
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this explicit syntax better actually, only if TS and ESLint played nice

@@ -1,10 +1,15 @@
module.exports = function () {
export default function wallabyConfig () {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently Wallaby says this is supported, but it never loads when choosing this config

@evelynhathaway evelynhathaway added the enhancement New feature or request label May 21, 2021
@evelynhathaway evelynhathaway self-assigned this May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants