Skip to content

Commit

Permalink
Treeshakable maybe?
Browse files Browse the repository at this point in the history
  • Loading branch information
Pckool committed Aug 10, 2023
1 parent 8af8288 commit b2378fb
Show file tree
Hide file tree
Showing 8 changed files with 2,175 additions and 158 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@ngneat/falso": "^6.4.0",
"@nx/webpack": "^16.6.0",
"@testing-library/react": "^13.3.0",
"@trunkio/launcher": "^1.2.3",
"@types/fs-readdir-recursive": "^1.1.0",
Expand All @@ -57,10 +58,10 @@
"jsdoc-babel": "^0.5.0",
"jsdoc-to-markdown": "^8.0.0",
"jsdom": "^20.0.1",
"lerna": "7.1.1",
"lerna": "^7.1.5",
"node-fetch": "2",
"nodemon": "^2.0.15",
"nx": "16.5.1",
"nx": "^16.6.0",
"pinst": "^2.1.6",
"prettier": "^2.8.0",
"react": "^18",
Expand Down
1 change: 1 addition & 0 deletions packages/plexus-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"react",
"reactjs",
"global state",
"shared state",
"plugin"
],
"license": "MIT",
Expand Down
12 changes: 0 additions & 12 deletions packages/plexus-core/src/collection/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,6 @@ export class CollectionInstance<
return this
}
let g = this.getGroup(group as GroupName)
// if the group does not exist, create it. This should technically never happen because of getGroup, but leaving here for redundancy
// ! 08/03 - commenting out to see if we can remove this safely
// if (!g) {
// g = _group(
// () => this.instance(),
// () => this,
// group,
// { sort: this._internalStore.sort }
// )
// this._internalStore._groups.set(group as GroupName, g)
// }
g.add(keys)
}
const parseAndPushGroups = () => {
Expand Down Expand Up @@ -1018,7 +1007,6 @@ export class CollectionInstance<
*/
get size() {
// should we remove provisional items from the count? If so this is a prototype of how to do it
// return this._internalStore._data.size - this._internalStore._provisionalCount
return this._internalStore._data.size
}
}
Expand Down
21 changes: 0 additions & 21 deletions packages/plexus-core/src/collection/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class CollectionData<
this.mount()
this.syncForeignKeyData(true)
}
// this.syncForeignKeyData(!this.provisional)
}
/**
* The internal id of the state with an instance prefix
Expand Down Expand Up @@ -205,26 +204,7 @@ export class CollectionData<
makeWatcher(newKey, this.shallowValue?.[idKey] as string)
}
}
// const that = this
// this.foreignKeyData = new Proxy<any>(this.foreignKeyData, {
// get(target, prop, reciever) {
// console.log('get', prop, target, reciever)
// if (prop === newKey) {
// const freshValue =
// that
// .instance()
// .findReference(foreignKeys[idKey]?.reference || '')
// ?.getItem(that.primaryKey).shallowValue || undefined
// freshValue && delete freshValue[idKey]
// console.log('freshValue', freshValue)
// return freshValue
// }
// return Reflect.get(target, prop, reciever)
// },
// })
// console.log('get', foreignKeys, 'value', this.foreignKeyData?.[newKey])
}
// this.foreignKeyData = value
}
}
private genValue(incomingValue?: PlexusWatchableValueInterpreter<DataType>) {
Expand Down Expand Up @@ -343,7 +323,6 @@ export class CollectionData<
delete(): this {
this.collection().delete(this.key)
return this
// delete _internalStore._state
}
/**
* Clean this data instance (remove all watchers & remove the state from the instance)
Expand Down
1 change: 0 additions & 1 deletion packages/plexus-core/src/collection/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export class CollectionGroup<
newKeysAdded = true
this._internalStore._includedKeys.add(key)
}
// this._internalStore._includedKeys.add(key)
if (newKeysAdded) {
this.rebuildDataWatchers()
}
Expand Down
9 changes: 9 additions & 0 deletions project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"targets": {
"build": {
"options": {
"webpackConfig": "./webpack.config.js"
}
}
}
}
11 changes: 11 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { composePlugins, withNx } = require('@nx/webpack');
const { merge } = require('webpack-merge')

module.exports = composePlugins(withNx(), (config, { options, context }) => {
// customize webpack config here
return merge(config, {
optimization: {
sideEffects: true,
},
})
});
Loading

0 comments on commit b2378fb

Please sign in to comment.