Giter Club home page Giter Club logo

Comments (20)

kofrasa avatar kofrasa commented on July 19, 2024 1

Sorry for the breaking change. I tested both using require for CommonJS module and import for ES6 modules. Perhaps there was something amiss there. I will deprecate this version for now.

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024 1

Gotcha. I have verified the bug. Deprecating version 6.2.2 for now.

from mingo.

pubkey avatar pubkey commented on July 19, 2024 1

Setting sideEffects: false on the root package.json does not seem correct.
For example the code fills up the operators in the init here https://github.com/kofrasa/mingo/blob/master/src/init/system.ts which is a side effect because it directly runs on import and mutates a "global" state. The bundler would tree-shake out the system.ts which would then no longer work.

from mingo.

pubkey avatar pubkey commented on July 19, 2024 1

@kofrasa I am working on a PR.

from mingo.

ericyhwang avatar ericyhwang commented on July 19, 2024

I tested both using require for CommonJS module and import for ES6 modules. Perhaps there was something amiss there.

It works fine if requiring just the root package itself, because the main field in package.json maps it to lib/index.js. It only breaks when requiring a specific file inside the package, since that's still based on the actual filesystem paths.

// OK
require('mingo');
// Not OK
require('mingo/core');
require('mingo/init/system');

from mingo.

pubkey avatar pubkey commented on July 19, 2024

I still have the problem when building with typescript. (Non-typescript build works.)

broken-types

Reproduce: https://codesandbox.io/s/typescript-28-typescript-webpack-react-forked-6inzol?file=/src/index.tsx

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

Seemed to build fine from the link. Are you still seeing issues?

from mingo.

pubkey avatar pubkey commented on July 19, 2024

You have to leave the tab open for a while until the npm deps are installed in the background. Then the editor will show the import errors and that it is not able to find the types.

broken-type-2

I am investigating the root problem but atm. I have no clue. I tried modifying severeral parts in the package.json but that did not help.

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

Could this be an editor issue where it fails to process the "exports" definition in the package.json file?

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

The code seems to run fine without any errors. The editor error markers don't show for me even after waiting a while.

from mingo.

pubkey avatar pubkey commented on July 19, 2024

I have the same error when processing the types with plain typescript in the cli, without an editor.
See https://github.com/pubkey/rxdb/actions/runs/3855130020/jobs/6569861677

from mingo.

pubkey avatar pubkey commented on July 19, 2024

Settings "moduleResolution": "NodeNext" in the tsconfig seems to resolve the problem.
But strange that this is required to make it work.

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

I wasn't familiar with that value for "moduleResolution" but it seems to be what is required according to https://www.typescriptlang.org/tsconfig#moduleResolution.

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

You have to leave the tab open for a while until the npm deps are installed in the background. Then the editor will show the import errors and that it is not able to find the types.

broken-type-2

I am investigating the root problem but atm. I have no clue. I tried modifying severeral parts in the package.json but that did not help.

I see this now.

from mingo.

pubkey avatar pubkey commented on July 19, 2024

I think we should create one package.json for each submodule during build.
Similar to how rxjs does it. https://www.npmjs.com/package/rxjs?activeTab=explore
This would also allow us to set sideEffects: false in the submodules, but not in the root package.json.

With the current release, I also get problems on different bundlers, without typescript.
For example with the react native metro bundler:
metro-error

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

I only see a single package.json in rxjs. The files are actually pretty similar but I am missing the ./package.json in the export. Will publish a version with that included and the changes proposed.

from mingo.

pubkey avatar pubkey commented on July 19, 2024

There is only a single package.json in the rxjs github repo. But in the release package, there are different package.json files, one for each submodule. For example rxjs/ajax/package.json.
I cannot hotlink it on npm, but you can see it on the file explorer here https://www.npmjs.com/package/rxjs?activeTab=explore

Adding "./package.json": "./package.json" to the exports does not solve the problem I think.

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

I see what you mean. That seems to work for a flat structure. I may have to generate that for each nested operator module defined in this project.

For example it may work for mingo/core but would it work for mingo/operators/pipeline?

Do we create the entire folder structure with each level having their own package.json?

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

You are right. It looks like that's how it has to be. See https://www.npmjs.com/package/rxdb?activeTab=explore.

I modelled 6.2.3 exports after rxdb which seems to do just that.

from mingo.

pubkey avatar pubkey commented on July 19, 2024

Do we create the entire folder structure with each level having their own package.json?

No. When sideEffects: false is set, the bundler will automatically tree-shake the non-used code. So you only need to create package.json files for the main submodules, not for each single operator.

from mingo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.