Comments (20)
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.
Gotcha. I have verified the bug. Deprecating version 6.2.2
for now.
from mingo.
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.
@kofrasa I am working on a PR.
from mingo.
I tested both using
require
for CommonJS module andimport
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.
I still have the problem when building with typescript. (Non-typescript build works.)
Reproduce: https://codesandbox.io/s/typescript-28-typescript-webpack-react-forked-6inzol?file=/src/index.tsx
from mingo.
Seemed to build fine from the link. Are you still seeing issues?
from mingo.
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.
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.
Could this be an editor issue where it fails to process the "exports" definition in the package.json file?
from mingo.
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.
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.
Settings "moduleResolution": "NodeNext"
in the tsconfig seems to resolve the problem.
But strange that this is required to make it work.
from mingo.
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.
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.
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.
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:
from mingo.
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.
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.
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.
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.
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)
- $round is rounding down to even numbers even when it's above the .5 threshold HOT 4
- Regression in string matching in 4.3 HOT 7
- Question: Why has the generic type for Cursor been removed? HOT 3
- updateObject does not work for array of objects with the $pull operator HOT 8
- Add support for $median (aggregation) HOT 1
- Add support for $percentile (aggregation) HOT 2
- Add support for $bitAnd (aggregation)
- Add support for $bitNot (aggregation)
- Add support $bitOr (aggregation)
- Add support for $bitXor (aggregation)
- updateObject fails when the $exists operator is used with $pull HOT 2
- $push with updateObject does not create the array if the fields does not exist HOT 1
- $inc with updateObject does not create the field if it doesn't exist HOT 1
- aggregate() $group stage with mongodb object id as group key only creates one single group HOT 1
- aggregate() $project stage modifies original collection when using negative projection on nested field HOT 2
- TypeError: Cannot convert undefined or null to object HOT 9
- AWS SSO HOT 2
- query HOT 1
- $project step omits referenced properties when matching property exists in incoming data HOT 3
- Basic query operators not loaded by default for update operation. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mingo.