-
Notifications
You must be signed in to change notification settings - Fork 10
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
deepMerge is not a function #22
Comments
Hey - how are you using it? If you're using it within some CommonJS code with const merge = require("ts-deepmerge").default; Let me know if that helps. This package was designed for use within TS codebases with |
I'm using it in typescript. And I think I haven't compiled it to cjs. I'm looking into that {
"module": {
"type": "es6"
},
"jsc": {
"parser": {
"syntax": "typescript"
}
},
"sourceMaps": true
} tsconfig {
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"esModuleInterop": true,
"moduleResolution": "Node",
"noImplicitOverride": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"types": [
"mocha"
]
},
"ts-node": {
"swc": true
}
} |
Can you show me how you're importing it and attempting to use it? I've never encountered this sort of issue within a TS codebase before - it generally just works like this without any issues, so it may be something to do with the way your project is being compiled? import merge from "ts-deepmerge";
const obj = merge({ a: true }, { b: false }); I don't suppose your issue is being caused by |
I guess the ts-swc-loader Im using for test with mocha caused that. I'm trying to dig it. I don't know if it is respect my swc config. I think it isn't a problem of code import deepMerge from 'ts-deepmerge'
deepMerge({ title }, ...it) |
Hmm it seems like something specific to your config/setup is impacting it somehow and causing the module to return the CommonJS module object rather than the default export from the module which would require you to import it like this instead: import { default as merge } from "ts-deepmerge"; Would be good to try and track down what's causing it to behave differently though 🤔 Does removing the |
What's compiled manually(IDK if it as same as the loader's). Will it caused it? import deepMerge from "ts-deepmerge";
deepMerge.apply(void 0, [
{
title: title
}
].concat(_toConsumableArray(it))); |
Noop
|
I'm not too sure what you mean there. I just know that when consumed normally this issue doesn't occur. Has been tested in a number of different contexts (eg: using the TS compiler on its own, using Webpack etc) and they all resolve as expected. You can test it out in this bare-bones TS template repo of mine if you like and perhaps compare your config to that, because that one works. It's quite hard to debug your project without having access to it I'm afraid... It just seems like something within your stack is causing the module to return an object instead of the actual module. |
@SettingDust did you get this working in the end? Just wondering if I can close the issue 🙏 |
No. I've switched from swc to esbuild and still error. Still testing |
Can't explain the reason. Edit: seems there is a plugin to solve this https://www.npmjs.com/package/swc-plugin-node-cjs-interop |
Does that plugin enable it to work in your project? We have roughly 800 public GitHub repos depending on this package and none of them have had this issue, so it seems like it's a project configuration issue rather than an issue with the package itself. If that plugin has allowed it to work, please let me know and I'll close this issue. |
It's fine with https://github.com/qnighy/node-cjs-interop. The swc plugin not working qnighy/node-cjs-interop#43 |
I have same issue :( |
I have the same issue too. I made a reproduction that I think boils down to having "type": "module" in the consuming project's package.json. With it, typescript is happy to compile the code using this library, but the compiled code fails at runtime. Without it, everything works correctly. |
This seems to be a very similar problem and they have a workaround that may work here too without complicating the build hugely. |
Hmmm interesting... I'll have a look and see what I can do! 👀 |
I've just published a new version which now properly supports consumers that use either ESM or CommonJS syntax. Once you update to version |
Glorious! Thank you!
…On Thu, Jan 26, 2023 at 8:14 PM Voodoo Creation ***@***.***> wrote:
Closed #22 <#22> as
completed.
—
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ5N2N57GPFTT3OYSY6F7LWUMOOTANCNFSM6AAAAAARZJQ5QE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Now that the EKS addons are added we need to align them and do some cleanup. This involves: - adding the enums introduced in #1357 to the VPC CNI - exposing configurationValues for coredns and kube-proxy - removing kubectl from the provider - deeply sort addon configuration keys to guarantee stable json serialization - remove deepmerge again. It caused issues during unit tests (voodoocreation/ts-deepmerge#22) and when used on outputs. Additionally I discovered and fixed an old bug that luckily never surfaced. The VPC CNI configuration did incorrectly handle outputs and called `toString` on them in a couple of places. The increased type safety and tests around addon configuration uncovered this. Closes #1369
Now that the EKS addons are added we need to align them and do some cleanup. This involves: - adding the enums introduced in #1357 to the VPC CNI - exposing configurationValues for coredns and kube-proxy - removing kubectl from the provider - deeply sort addon configuration keys to guarantee stable json serialization - remove deepmerge again. It caused issues during unit tests (voodoocreation/ts-deepmerge#22) and when used on outputs. Additionally I discovered and fixed an old bug that luckily never surfaced. The VPC CNI configuration did incorrectly handle outputs and called `toString` on them in a couple of places. The increased type safety and tests around addon configuration uncovered this. Closes #1369
Now that the EKS addons are added we need to align them and do some cleanup. This involves: - adding the enums introduced in #1357 to the VPC CNI - exposing configurationValues for coredns and kube-proxy - removing kubectl from the provider - deeply sort addon configuration keys to guarantee stable json serialization - remove deepmerge again. It caused issues during unit tests (voodoocreation/ts-deepmerge#22) and when used on outputs. Additionally I discovered and fixed an old bug that luckily never surfaced. The VPC CNI configuration did incorrectly handle outputs and called `toString` on them in a couple of places. The increased type safety and tests around addon configuration uncovered this. Closes #1369
The compiled js can't use
The text was updated successfully, but these errors were encountered: