Draft
Conversation
Major changes: - All packages now use type:module for ESM - Replace main with exports in all package.json - Extend @foxglove/tsconfig/node.json in all tsconfig files - Add .js extensions to all relative imports (ESM requirement) - Delete tsconfig.cjs.json files (no more dual CJS/ESM builds) - Delete tsconfig.eslint.json and tsconfig.dts.json files - Update Jest configs for ESM support - Rename webpack.config.js and neTransformer.js to .cjs - Add type declarations for packages without NodeNext exports BREAKING CHANGE: All packages now require ESM imports. CJS consumers must use dynamic import() instead of require(). Co-authored-by: adrian <adrian@foxglove.dev>
Contributor
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: adrian <adrian@foxglove.dev>
- Add NODE_OPTIONS='--experimental-vm-modules' to Jest test scripts for ESM support - Fix xmlrpc examples with type:module and verbatimModuleSyntax:false - Use ESM-compatible directory resolution (fileURLToPath) instead of __dirname - Add jest setup files for custom matchers (rosmsg2-serialization) and polyfills (rosbag2-web) - Update rosmsg webpack to output ESM format instead of commonjs2 - Fix nearley import for ESM compatibility (use default import) - Restore benchmark scripts and dependencies to rosmsg-serialization - Fix CI workflow to call correct package for benchmark Co-authored-by: adrian <adrian@foxglove.dev>
Consistent ordering: name, version, description, license, private (if relevant), type:module, keywords, repository, author, homepage, exports, files, bin, scripts, engines, dependencies, devDependencies Co-authored-by: adrian <adrian@foxglove.dev>
Co-authored-by: adrian <adrian@foxglove.dev>
The rosmsg package uses webpack to bundle with nearley-loader, which outputs CommonJS format. Having type:module in package.json caused Node.js to try to load the CJS bundle as ESM, breaking imports in Jest ESM mode. Also reverted attempted .ts import extension changes - the approach doesn't work well with webpack's CJS output and Jest ESM mode due to CJS/ESM interop issues. Keeping .js extensions in imports. Co-authored-by: adrian <adrian@foxglove.dev>
The upstream @foxglove/tsconfig/node.json already has rewriteRelativeImportExtensions: true. Since our source imports already use .js extensions, the rewriting works correctly and we don't need to override it to false. Co-authored-by: adrian <adrian@foxglove.dev>
- Remove webpack and related dependencies (ts-loader, nearley-loader, webpack-cli) - Add compile-grammar.js script to compile nearley grammar to ESM format - Move moo and nearley from devDependencies to dependencies (runtime requirements) - Add type: module to package.json now that we output proper ESM - Remove tsconfig.webpack.json and webpack.config.cjs - Add ros1Grammar.d.ts for TypeScript type definitions - Add generated grammar file to .gitignore and eslint ignores This simplifies the build process by using tsc directly instead of webpack, resulting in proper ESM output with named exports. Co-authored-by: adrian <adrian@foxglove.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modernize TypeScript configuration and package exports to standardize all packages to use native ESM.
This PR updates all packages to use native ESM by setting
type: moduleandexportsfields inpackage.json, and extending@foxglove/tsconfig/node.json. It removes legacy CJS build configurations and updates internal imports to use.jsextensions. This is a breaking change (semver major) for consumers relying on CJSrequire(). Workarounds for external dependencies lacking proper NodeNext exports are included.