Fix ES module imports and CLI kernel reference#452
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…, fix package.json entries Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request addresses ES module resolution issues in the ObjectStack monorepo and corrects an incorrect class import in the CLI package. The changes ensure proper ES module compatibility across three packages by adding .js extensions to relative imports and fixing package entry points.
Changes:
- Fixed incorrect kernel class reference from
ObjectStackKerneltoObjectKernelin CLI serve command - Added
.jsextensions to all relative imports in@objectstack/objectqland@objectstack/runtimepackages - Updated
@objectstack/objectqlpackage.json to point to compileddist/files instead of sourcesrc/files
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/cli/src/commands/serve.ts | Corrects the kernel import from non-existent ObjectStackKernel to the correct ObjectKernel export |
| packages/runtime/src/rest-server.ts | Adds .js extension to local route-manager import for ES module compliance |
| packages/objectql/src/protocol.ts | Adds .js extension to local registry import |
| packages/objectql/src/plugin.ts | Adds .js extensions to local engine and protocol imports |
| packages/objectql/src/index.ts | Adds .js extensions to all local module exports |
| packages/objectql/src/engine.ts | Adds .js extension to local registry import |
| packages/objectql/package.json | Updates main and types entry points from src/ to dist/ directory |
| "description": "Isomorphic ObjectQL Engine for ObjectStack", | ||
| "main": "src/index.ts", | ||
| "types": "src/index.ts", | ||
| "main": "dist/index.js", |
There was a problem hiding this comment.
The package.json is missing the "type": "module" field. Since this package now uses ES module imports with .js extensions and points to compiled dist/ files, it should declare itself as an ES module. Without this field, Node.js will treat .js files as CommonJS, which will cause module resolution failures. Other packages in the monorepo (@objectstack/core and @objectstack/runtime) already have this field set.
| "main": "dist/index.js", | |
| "main": "dist/index.js", | |
| "type": "module", |
Fixes ES module resolution failures and incorrect class import preventing CLI operation.
Changes
@objectstack/cliObjectStackKernel→ObjectKernelin serve command (correct export from@objectstack/core)@objectstack/runtime@0.7.2.jsextension toroute-managerimport inrest-server.ts@objectstack/objectql@0.7.2mainandtypesnow point todist/instead ofsrc/.jsextensions to all relative imports inindex.ts,plugin.ts,engine.ts,protocol.tsExample
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.