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

Type declarations depend on dev dependencies #136

Closed
gsvarovsky opened this issue Apr 7, 2021 · 9 comments
Closed

Type declarations depend on dev dependencies #136

gsvarovsky opened this issue Apr 7, 2021 · 9 comments
Labels
bug dependencies Pull requests that update a dependency file

Comments

@gsvarovsky
Copy link
Contributor

When importing quadstore@9 into a dependent project using Typescript:

node_modules/quadstore/dist/lib/quadstore.d.ts:6:25 - error TS2307: Cannot find module 'sparqlalgebrajs' or its corresponding type declarations.

6 import { Algebra } from 'sparqlalgebrajs';
                          ~~~~~~~~~~~~~~~~~

node_modules/quadstore/dist/lib/quadstore.d.ts:8:30 - error TS2307: Cannot find module '@comunica/types' or its corresponding type declarations.

8 import { IQueryEngine } from '@comunica/types';
                               ~~~~~~~~~~~~~~~~~

These modules are dev dependencies.

As types have no runtime cost I think it might be fine to make @comunica/types a core dependency. However for sparqlalgebra a bundler might pull that project into the runtime. Perhaps type-only imports & exports can help here?

@jacoscaz
Copy link
Owner

jacoscaz commented Apr 7, 2021

This is an unfortunate situation that I'm not really sure how to get out of.

  1. If I add those dependencies as normal dependencies, NPM will install them and unnecessarily inflate the node_modules folder with stuff that is not really needed.
  2. If I add those dependencies as normal dependencies, bundlers might indeed pull them in (and their own dependencies!). However, this does looks like it can be solved by using type-only imports & exports as you mentioned.
  3. If I keep them as devDependencies they'll always result in this sort of error.

What would you do?

@gsvarovsky
Copy link
Contributor Author

To just complete the picture for my use-case: m-ld-js uses the sparqlalgebrajs factory to construct algebra objects. So I have to pull in this module myself anyway. This means it's bundled twice, as it's already in the quadstore-comunica bundle.

@jacoscaz
Copy link
Owner

jacoscaz commented Apr 7, 2021

To just complete the picture for my use-case: m-ld-js uses the sparqlalgebrajs factory to construct algebra objects. So I have to pull in this module myself anyway. This means it's bundled twice, as it's already in the quadstore-comunica bundle.

Oh boy. I was not expecting that. Apologies, then - your bundle size must have grown a little bit. The reason I moved sparqlalgebrajs inside the quadstore-comunica bundle is that parsing needs to happen within Comunica for some SPARQL tests to succeed. I will revert to having sparqlalgebrajs outside of that bundle while still keeping Comunica's SPARQL parser actor around.

@gsvarovsky
Copy link
Contributor Author

I think it may be possible for quadstore-comunica to export all of sparqlalgebrajs and the types from comunica.

@jacoscaz
Copy link
Owner

jacoscaz commented Apr 7, 2021

I think it may be possible for quadstore-comunica to export all of sparqlalgebrajs and the types from comunica.

This would be possible, yes, but it would not lend itself well to use cases dealing with custom Comunica configurations other than quadstore-comunica. Reverting to shipping sparqlalgebrajs as a dependency of quadstore but keeping the SPARQL parser actor in the quadstore-comunica bundle and forcing the latter to require sparqlalgebrajs via Webpack (as it was pre-9.0) should make everyone happy.

You can expect a fix by the end of the day. Thank you for raising this!

@jacoscaz jacoscaz added bug dependencies Pull requests that update a dependency file labels Apr 7, 2021
@gsvarovsky
Copy link
Contributor Author

Thanks! No problem & no huge rush.

The good news is that with a temporary import of these deps, m-ld-js+quadstore@9 is passing all unit & compliance tests!

@jacoscaz
Copy link
Owner

jacoscaz commented Apr 7, 2021

Hello again @gsvarovsky !

Could you please try again with quadstore@9.1.0-beta.0 and quadstore-comunica@1.1.0-beta.0?

@gsvarovsky
Copy link
Contributor Author

Could you please try again

It works!

@jacoscaz
Copy link
Owner

jacoscaz commented Apr 7, 2021

Fixed in quadstore@9.1.0 and quadstore-comunica@1.1.0.

@jacoscaz jacoscaz closed this as completed Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants