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

bio-parsers npm package lacks the "type": "module" decalration, cannot be used on backend #107

Open
V3rt3Xk3 opened this issue Nov 14, 2024 · 4 comments

Comments

@V3rt3Xk3
Copy link

@tnrich

Hi, thank you for your work!!!

I was unable to import the genbank to json parser. In the github repositorythe code is correct, but the npm package lacks the type setting.

Fixed packages.json, now i can import the

import {genbankToJson} from '@teselagen/bio-parsers';

{
"type": "module",
"name": "@teselagen/bio-parsers",
"version": "0.4.22",
"dependencies": {
"@teselagen/sequence-utils": "0.3.27",
"@teselagen/range-utils": "0.3.7",
"@gmod/gff": "^1.2.1",
"buffer": "^6.0.3",
"bufferpack": "^0.0.6",
"color": "^4.2.3",
"fast-xml-parser": "^4.2.5",
"fflate": "^0.8.0",
"lodash-es": "^4.17.21",
"string_decoder": "^1.3.0",
"validate.io-nonnegative-integer-array": "^1.0.1"
},
"license": "MIT"
}

Original packages.json (missing type declaration)
{
"name": "@teselagen/bio-parsers",
"version": "0.4.22",
"dependencies": {
"@teselagen/sequence-utils": "0.3.27",
"@teselagen/range-utils": "0.3.7",
"@gmod/gff": "^1.2.1",
"buffer": "^6.0.3",
"bufferpack": "^0.0.6",
"color": "^4.2.3",
"fast-xml-parser": "^4.2.5",
"fflate": "^0.8.0",
"lodash-es": "^4.17.21",
"string_decoder": "^1.3.0",
"validate.io-nonnegative-integer-array": "^1.0.1"
},
"license": "MIT"
}

The "type": "module" is missing. I am new to typescript but without this I was not able to use your code on backend. (Node20, typescript)

My import was always complaining about syntax errors regarding an unexpected token: export.
Also I have installed the package with this npm command: npm install -S @teselagen/bio-parsers

Also if it like this by design then please let me know and I do a fork :), thanks

@V3rt3Xk3
Copy link
Author

I get this without the addition to type: module in package json of the bio-parsers module:

(node:21648) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)
D:\Repos\t1l3s_sequence_format_converter\bio-parsers-api\node_modules@teselagen\bio-parsers\index.js:29084
export {
^^^^^^

SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at cjsLoader (node:internal/modules/esm/translators:356:17)
at ModuleWrap. (node:internal/modules/esm/translators:305:7)
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)

Node.js v20.11.1

@tnrich
Copy link
Collaborator

tnrich commented Nov 19, 2024

@V3rt3Xk3 would you like to make a pull request with your suggested code changes?

Thanks!

@V3rt3Xk3
Copy link
Author

V3rt3Xk3 commented Nov 27, 2024

Hi @tnrich ,

I am very new to both typescript and open source. I would be delighted if I could join in maintaining this gem, but i might need to guiding thoughts, please see below.

Thank you for believing in me! :) I will try to approach the issue from the DevOps point of view.

I have been playing with the fork, i might need to refork it again though, and start playing on separate branches. I will look into what i can do about it on the weekend. I have made a fix but the typescript part needed to be hacked into the package i published with your infrastructure.

Can you maybe give me a hint or steps on how you exactly publish now? The tsc does not seem to put the exports into the correct place. It is saying that the typescript types and artifacts are being emitted outside of my repository. I might be even able to share a publish log with you.

I would be happy if you could summarize the publish procedure to one of the packages that actually results in the typescript files emitted into the package itself. My attempts excluded the ts artifacts. PS: I followed the documentation on the repository.

All the best

@tnrich
Copy link
Collaborator

tnrich commented Dec 4, 2024

Hi @V3rt3Xk3 without looking at the code it is hard for me to diagnose what is going wrong or what you're trying to do exactly.

Is the repo you're working in open source? If so can you link it here?

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

No branches or pull requests

2 participants