Skip to content

Conversation

@thomas-lebeau
Copy link
Collaborator

@thomas-lebeau thomas-lebeau commented Oct 8, 2025

Motivation

Remove the annoying MODULE_TYPELESS_PACKAGE_JSON warning when running most of the node command.

Changes

Test instructions

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@cit-pr-commenter
Copy link

cit-pr-commenter bot commented Oct 8, 2025

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 162.96 KiB 162.96 KiB 0 B 0.00%
Rum Recorder 19.78 KiB 19.78 KiB 0 B 0.00%
Rum Profiler 4.89 KiB 4.89 KiB 0 B 0.00%
Logs 56.62 KiB 56.62 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 119.90 KiB 119.90 KiB 0 B 0.00%
Worker 23.60 KiB 23.60 KiB 0 B 0.00%
🚀 CPU Performance

Pending...

🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 25.21 KiB 25.43 KiB +231 B
RUM - add action 44.16 KiB 45.15 KiB +1016 B
RUM - add timing 25.31 KiB 24.88 KiB -439 B
RUM - add error 49.92 KiB 50.87 KiB +966 B
RUM - start/stop session replay recording 24.59 KiB 24.06 KiB -544 B
RUM - start view 421.27 KiB 427.02 KiB +5.76 KiB
Logs - log message 41.63 KiB 42.29 KiB +675 B

🔗 RealWorld

@datadog-official
Copy link

datadog-official bot commented Oct 8, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 100.00%
Total Coverage: 92.64% (+0.00%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e44f9de | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/module-typeless-package-json branch 3 times, most recently from 40a2024 to bf31991 Compare October 9, 2025 09:50
@BenoitZugmeyer BenoitZugmeyer force-pushed the thomas.lebeau/module-typeless-package-json branch from bf31991 to 656b69b Compare October 31, 2025 13:16
BenoitZugmeyer and others added 9 commits October 31, 2025 14:45
…y getRunId function to return 'n/a' if no CI_JOB_ID or USER is set
…ProdDepsImports

- Implemented disallowProtectedDirectoryImport to prevent importing from directories containing an "index" file.
- Created enforceProdDepsImports to ensure only production dependencies are imported in production files.
- Updated index.js to include the new rules.
@thomas-lebeau thomas-lebeau marked this pull request as ready for review October 31, 2025 15:01
@thomas-lebeau thomas-lebeau requested a review from a team as a code owner October 31, 2025 15:01
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +4 to +10
import resolvePackage from 'eslint-module-utils/resolve.js'
import moduleVisitorPackage from 'eslint-module-utils/moduleVisitor.js'
import importTypePackage from 'eslint-plugin-import/lib/core/importType.js'

const moduleVisitor = moduleVisitorPackage.default
const importType = importTypePackage.default
const resolve = resolvePackage.default

Choose a reason for hiding this comment

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

P0 Badge Preserve default exports when importing ESLint helper utilities

The refactor to ESM imports replaces require('…').default with import … from '…'; const fn = imported.default. In ESM, the value bound by import foo from 'pkg' is already the default export; accessing .default again yields undefined when the module exports a function. As a result moduleVisitor, importType, and resolve are undefined and the rule throws as soon as it runs. Import the default directly (import moduleVisitor from 'eslint-module-utils/moduleVisitor.js') or fall back to the object when default is missing.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

@thomas-lebeau thomas-lebeau Nov 4, 2025

Choose a reason for hiding this comment

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

these modules are weird, we need the default key from the default export 🙄

[Module: null prototype] {
  CASE_SENSITIVE_FS: false,
  __esModule: true,
  default: {
    __esModule: true,
    CASE_SENSITIVE_FS: false,
    fileExistsWithCaseSync: [Function: fileExistsWithCaseSync],
    relative: [Function: relative],
    default: [Function: resolve] { relative: [Function: relative] }
  },
  fileExistsWithCaseSync: [Function: fileExistsWithCaseSync],
  'module.exports': {
    __esModule: true,
    CASE_SENSITIVE_FS: false,
    fileExistsWithCaseSync: [Function: fileExistsWithCaseSync],
    relative: [Function: relative],
    default: [Function: resolve] { relative: [Function: relative] }
  },
  relative: [Function: relative]
}

Comment on lines +3 to +9
import moduleVisitorPackage from 'eslint-module-utils/moduleVisitor.js'
import importTypePackage from 'eslint-plugin-import/lib/core/importType.js'
import pkgUpPackage from 'eslint-module-utils/pkgUp.js'

const moduleVisitor = moduleVisitorPackage.default
const pkgUp = pkgUpPackage.default
const importType = importTypePackage.default

Choose a reason for hiding this comment

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

P0 Badge Default import handling breaks ESLint rule initialisation

Similar to the protected-directory rule, these helpers are now imported via import … from … and immediately dereferenced with .default. When eslint-module-utils/eslint-plugin-import are ESM bundles, the default import already returns the function; .default is undefined and the rule fails at runtime (TypeError: pkgUp is not a function). Linting will abort before running. Use the default import directly or guard against missing default.

Useful? React with 👍 / 👎.

}

const packagesRoot = path.resolve(__dirname, '..', 'packages')
const packagesRoot = path.resolve(import.meta.dirname, '..', 'packages')

Choose a reason for hiding this comment

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

P1 Badge import.meta.dirname usage requires a newer Node than project declares

The rule now resolves packagesRoot via path.resolve(import.meta.dirname, …). import.meta.dirname is only available starting with Node 22; with the current project setup (no engine bump and the repository historically using Node 18/20), this property is undefined, causing the rule to crash when ESLint is loaded. To remain compatible with supported Node versions, compute the directory using fileURLToPath(new URL('.', import.meta.url)) or similar.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we use node 24

Comment on lines +4 to +10
import resolvePackage from 'eslint-module-utils/resolve.js'
import moduleVisitorPackage from 'eslint-module-utils/moduleVisitor.js'
import importTypePackage from 'eslint-plugin-import/lib/core/importType.js'

const moduleVisitor = moduleVisitorPackage.default
const importType = importTypePackage.default
const resolve = resolvePackage.default
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ question: ‏Not from this PR, but are we using internals here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it seems so

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Well, maybe eslint-plugin-import/lib/core/importType.js is internal :D

Copy link
Contributor

Choose a reason for hiding this comment

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

❓ question: ‏I remember seeing an explanation for this in Slack. How can we keep the explanation in the codebase so we don't forget why we need this as private?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

test/e2e is not type: module because in some scenario we import some build cjs files (example)

Indeed this is a bit of a hack, but this PR already improve things and we can always review the e2e test to not rely on these cjs file later.

I can't add comment to a package.json file, I guess blaming this file will make this PR (and this comment) visible.

@@ -1,6 +1,6 @@
const path = require('path')
import path from 'path'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import path from 'path'
import path from 'node:path'

@@ -1,6 +1,6 @@
const path = require('path')
import path from 'path'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import path from 'path'
import path from 'node:path'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would that work for you if I fix these in a separate PR using import/enforce-node-protocol-usage? there is a lot more than these few instances.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wip: #3943

@@ -1,12 +1,12 @@
const os = require('os')
import os from 'os'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import os from 'os'
import os from 'node:os'

@thomas-lebeau thomas-lebeau merged commit e059b81 into main Nov 4, 2025
21 checks passed
@thomas-lebeau thomas-lebeau deleted the thomas.lebeau/module-typeless-package-json branch November 4, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants