You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If flow-remove-types is run in a repo where package.json contains "type": "module" then it will fail. This occurs with the latest version of flow-remove-types (2.147.0) and flow (0.147.0). I've thrown together an example repo for reproduction: https://github.com/callumgare/example-flow-node-es-modules-fail
When running npx flow-remove-types index.js in the above repo with node 14 under ubuntu I get:
file:///home/callumgare/repos/flow-node-test/index.js:2
function main(val: string) {
^
SyntaxError: Unexpected token ':'
at Loader.moduleStrategy (internal/modules/esm/translators.js:141:18)
at async link (internal/modules/esm/module_job.js:42:21)
The text was updated successfully, but these errors were encountered:
flow-remove-types works by hooking into require (via pirates), so it only works with CJS. to work with ESM, we need to use node's loaders which are still experimental and say "Note: The loaders API is being redesigned. This hook may disappear or its signature may change. Do not rely on the API described below"
So I think we'll wait until it's stable so we don't cause ourselves issues in the future. We decided to go back to require for flow-dev-tools until native ESM fully works in node. see 50ee686
If
flow-remove-types
is run in a repo where package.json contains"type": "module"
then it will fail. This occurs with the latest version of flow-remove-types (2.147.0) and flow (0.147.0). I've thrown together an example repo for reproduction: https://github.com/callumgare/example-flow-node-es-modules-failWhen running
npx flow-remove-types index.js
in the above repo with node 14 under ubuntu I get:The text was updated successfully, but these errors were encountered: