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
npm install --save @nginx/reference-lib in the "server" part of the extension
add a import { find } from '@nginx/reference-lib'
run the server by itself, should work fine via tsc && node out/server.js
run the server inside the extension dev host, get an error:
Uncaught Error Error: require() of ES Module .../server/node_modules/@nginx/reference-lib/dist/index.js from .../server/out/server.js not supported.
Futzing around with various arcane tsconfig.json or package.json settings could get different errors, like
Uncaught ReferenceError ReferenceError: exports is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and '...server/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
or
Uncaught Error Error: Cannot find module '.../server/node_modules/vscode-languageserver/node' imported from .../server/out/server.js Did you mean to import "vscode-languageserver/node.js"?
Expected behavior
Extension dev host can import the library.
Your environment
node 23.11
macos
Additional context
Asking AI didn't really help. It just repeatedly told me to set things in json files that I already had, or suggested that the lib needed to be published differently to supports modules and commonjs, but all this packaging stuff is not my area of expertise.
The text was updated successfully, but these errors were encountered:
Describe the bug
Something about the bundling process isn't working right, and I don't know enough about npm/typescript packaging to be clear and concise.
To reproduce
Steps to reproduce the behavior:
npm install --save @nginx/reference-lib
in the "server" part of the extensionimport { find } from '@nginx/reference-lib'
tsc && node out/server.js
Futzing around with various arcane
tsconfig.json
orpackage.json
settings could get different errors, likeor
Expected behavior
Extension dev host can import the library.
Your environment
Additional context
Asking AI didn't really help. It just repeatedly told me to set things in json files that I already had, or suggested that the lib needed to be published differently to supports modules and commonjs, but all this packaging stuff is not my area of expertise.
The text was updated successfully, but these errors were encountered: