aralroca / default-composer Goto Github PK
View Code? Open in Web Editor NEWA tiny (~500B) JavaScript library that allows you to set default values for nested objects
License: MIT License
A tiny (~500B) JavaScript library that allows you to set default values for nested objects
License: MIT License
First of all: thank you for this nice tiny lib! ๐
What version of this package are you using?
0.5.0
What operating system, Node.js, and npm version?
node: v18.15.0
, yarn: 4.0.0-rc.45
What happened?
I would like to use default-composer
in a NextJS-Project and got the following error on importing:
next:dev: Module not found: Default condition should be last one
...
next:dev: > 4 | import { defaultComposer } from "default-composer";
Accoording to Node-Specification about conditional exports:
"default" - the generic fallback that always matches. Can be a CommonJS or ES module file. This condition should always come last.
I tried to change it locally from:
"exports": {
"require": "./dist/index.js",
"default": "./dist/index.modern.mjs",
"types": "./dist/index.d.ts"
}
to
"exports": {
"require": "./dist/index.js",
"types": "./dist/index.d.ts",
"default": "./dist/index.modern.mjs"
}
and the error is gone.
Could you please have a look.
What problem do you want to solve?
Use this module in a non npm/yarn setup.
Proposed use case:
Use this library as a <script type="module"
import directly in the browser.
Are you willing to submit a pull request to implement this change?
Maybe with some guidance.
What version of this package are you using?
0.5.1
What operating system, Node.js, and npm version?
Windows, node 18.15.0, npm 9.6.3
What happened?
Passing through default-composer make object to lose methods and other attributes
See code below:
import { unit, isUnit } from "mathjs";
import { defaultComposer } from "default-composer";
const def = {
a: unit(0, "mm"),
b: unit(0, "mm"),
c: unit(0, "mm"),
};
const dim = {
a: unit(1, "mm"),
b: unit(2, "mm"),
c: unit(3, "mm"),
};
console.log(isUnit(dim.a)); // returns true since a is of type mathjs.Unit
const full = defaultComposer(def, dim);
console.log(isUnit(full.a)); // returns false since a is missing of some attributes of mathjs.Unit
I think that during the 'compose' function, you not check for methods (aka functions) on object and (maybe) other stuffs. This make a complex object to lose some attributes.
"default-composer": "^0.4.0"
NODE v16.13.0 NPM 16.13.0 (Currently using 64-bit executable)
Failed to compile on npm start
Failed to compile.
Module parse failed: Unexpected token (30:33)
| },
| p = o(b),
s = e.isDefaultableValue?.(_objectSpread({}, b, {
| defaultableValue: p
| })) ?? p;
I expected the app to start
Sorry I cannot submit pull request due to NDA
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.