Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package.json should be updated to support TypeScripts bundler module resolution #247

Closed
DavidZidar opened this issue Sep 15, 2023 · 6 comments · Fixed by #248, #257 or #258
Closed

package.json should be updated to support TypeScripts bundler module resolution #247

DavidZidar opened this issue Sep 15, 2023 · 6 comments · Fixed by #248, #257 or #258
Assignees
Labels
bug Something isn't working

Comments

@DavidZidar
Copy link

I am trying to use TypeScripts "moduleResolution": "Bundler"-feature and I'm blocked by the sass-embedded-package.

This is the error that I'm getting from TypeScript:

buildscript.ts:1:30 - error TS7016: Could not find a declaration file for module 'sass-embedded'. '/projectPath/node_modules/sass-embedded/dist/lib/index.mjs' implicitly has an 'any' type.
There are types at '/projectPath/node_modules/sass-embedded/dist/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'sass-embedded' library may need to update its package.json or typings.

From what I can gather it seems that it is no longer enough to specify "types": "dist/types/index.d.ts", the package file should also include the types in exports as well.

@nex3
Copy link
Contributor

nex3 commented Sep 15, 2023

It looks like somehow we aren't shipping TypeScript types at all, so we should probably fix that too 😅.

@nex3 nex3 self-assigned this Sep 15, 2023
@nex3 nex3 added the bug Something isn't working label Sep 15, 2023
nex3 added a commit that referenced this issue Sep 15, 2023
We need to copy the entrypoing typings file, as described in [the
TypeScript docs]:

> It’s important to note that the CommonJS entrypoint and the ES
> module entrypoint each needs its own declaration file, even if the
> contents are the same between them. Every declaration file is
> interpreted either as a CommonJS module or as an ES module, based on
> its file extension and the `"type"` field of the `package.json`, and
> this detected module kind must match the module kind that Node will
> detect for the corresponding JavaScript file for type checking to be
> correct. Attempting to use a single `.d.ts` file to type both an ES
> module entrypoint and a CommonJS entrypoint will cause TypeScript to
> think only one of those entrypoints exists, causing compiler errors
> for users of the package.

[the TypeScript docs]: https://www.typescriptlang.org/docs/handbook/esm-node.html

Closes #247
nex3 added a commit that referenced this issue Sep 15, 2023
We need to copy the entrypoing typings file, as described in [the
TypeScript docs]:

> It’s important to note that the CommonJS entrypoint and the ES
> module entrypoint each needs its own declaration file, even if the
> contents are the same between them. Every declaration file is
> interpreted either as a CommonJS module or as an ES module, based on
> its file extension and the `"type"` field of the `package.json`, and
> this detected module kind must match the module kind that Node will
> detect for the corresponding JavaScript file for type checking to be
> correct. Attempting to use a single `.d.ts` file to type both an ES
> module entrypoint and a CommonJS entrypoint will cause TypeScript to
> think only one of those entrypoints exists, causing compiler errors
> for users of the package.

[the TypeScript docs]: https://www.typescriptlang.org/docs/handbook/esm-node.html

Closes #247
@nex3 nex3 closed this as completed in #248 Sep 18, 2023
nex3 added a commit that referenced this issue Sep 18, 2023
We need to copy the entrypoing typings file, as described in [the
TypeScript docs]:

> It’s important to note that the CommonJS entrypoint and the ES
> module entrypoint each needs its own declaration file, even if the
> contents are the same between them. Every declaration file is
> interpreted either as a CommonJS module or as an ES module, based on
> its file extension and the `"type"` field of the `package.json`, and
> this detected module kind must match the module kind that Node will
> detect for the corresponding JavaScript file for type checking to be
> correct. Attempting to use a single `.d.ts` file to type both an ES
> module entrypoint and a CommonJS entrypoint will cause TypeScript to
> think only one of those entrypoints exists, causing compiler errors
> for users of the package.

[the TypeScript docs]: https://www.typescriptlang.org/docs/handbook/esm-node.html

Closes #247
@DavidZidar
Copy link
Author

@nex3 Just saw you finally released this update, but this still isn't working unfortunately. The paths do not seem to be correct either?

From your package.json:

"exports": {
  "import": {
    "types": "./dist/lib/index.m.d.ts",
    "default": "./dist/lib/index.mjs"
  },
  "types": "./dist/lib/index.d.ts",
  "default": "./dist/lib/index.js"
}

I can only find types under ./dist/types/, not ./dist/lib/, and there is no .m.d.ts-file at all.

@nex3 nex3 reopened this Oct 11, 2023
nex3 added a commit that referenced this issue Oct 11, 2023
@nex3 nex3 closed this as completed in #257 Oct 11, 2023
nex3 added a commit that referenced this issue Oct 11, 2023
@ntkme
Copy link
Contributor

ntkme commented Oct 13, 2023

@ntkme
Copy link
Contributor

ntkme commented Oct 16, 2023

@nex3 1.69.3 wasn't released due to the following issue. I think we should reopen this and try again?

Error: cp: no such file or directory: dist/lib/src/vendor/sass/index.d.ts
    at Object.error (/home/runner/work/embedded-host-node/embedded-host-node/node_modules/shelljs/src/common.js:110:27)
    at /home/runner/work/embedded-host-node/embedded-host-node/node_modules/shelljs/src/cp.js:246:14
    at Array.forEach (<anonymous>)
    at Object._cp (/home/runner/work/embedded-host-node/embedded-host-node/node_modules/shelljs/src/cp.js:243:11)
    at Object.cp (/home/runner/work/embedded-host-node/embedded-host-node/node_modules/shelljs/src/common.js:384:25)
    at /home/runner/work/embedded-host-node/embedded-host-node/tool/prepare-release.ts:20:11

@nex3 nex3 reopened this Oct 17, 2023
@nex3
Copy link
Contributor

nex3 commented Oct 17, 2023

😩

@DavidZidar
Copy link
Author

I think it's working now, thanks @nex3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants