-
Notifications
You must be signed in to change notification settings - Fork 297
v3.0.0 + TypeScript Cannot find module 'redux-actions' from ... #390
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
Comments
The applied typescript configuration still transpiles to node's require:
This doesn't work with the ESM only build we currently have. @timche this could be a case why a commonJS export still might have relevance. |
@kaelig With this configuration it should work: https://replit.com/@alexander-heimb/ReduxActionsV3BugReportTS v3.0.0 provides the same API as v2.6.5, so for projects that might not be able to switch to ESM this should work as well. I will close this bug but if you that doesn't solve your issue feel free to reopen it. |
Thank you! Simply adding the types did fix the build. That said, for some reason our Jest + Any tips appreciated! |
Hey @kaelig, |
Oh, what a fun coincidence! Here's our import hq from 'alias-hq';
const ESM_NODE_MODULES = {
'@devcycle/devcycle-js-sdk/node_modules/uuid/*': ['uuid'],
'@storybook/addon-docs/*': ['@mdx-js/react'],
'markdown-table': undefined,
'node-fetch': ['data-uri-to-buffer', 'fetch-blob', 'formdata-polyfill'],
'parse-domain': ['ip-regex', 'is-ip'],
'react-markdown': [
'bail',
'decode-named-character-reference',
'hast-util-whitespace',
'is-plain-obj',
'mdast-util-from-markdown',
'mdast-util-to-hast',
'micromark',
'remark-rehype',
'trim-lines',
'trough',
'unified',
'unist-util-generated',
],
'strip-ansi': ['ansi-regex'],
};
const ignoreESMNodeModules = (delimiter = '|') => {
return `<rootDir>/node_modules/(?!${Object.entries(ESM_NODE_MODULES)
.map(([key, values = []]) => [key, ...values].join(delimiter))
.join(delimiter)})`;
};
/** @type {import('jest').Config} */
// eslint-disable-next-line import/no-anonymous-default-export
export default {
setupFiles: ['<rootDir>/test/setup.ts', 'jest-canvas-mock'],
setupFilesAfterEnv: ['<rootDir>/test/setupAfterEnv.ts'],
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
parser: {
syntax: 'typescript',
decorators: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
experimental: {
plugins: [['jest_workaround', {}]],
},
},
},
],
},
transformIgnorePatterns: [ignoreESMNodeModules()],
automock: false,
testMatch: [
'<rootDir>/(src|functions)/**/*.spec.[jt]s?(x)',
'<rootDir>/*.spec.[jt]s?(x)',
],
modulePaths: ['<rootDir>/src', '<rootDir>/test'],
moduleFileExtensions: ['js', 'cjs', 'json', 'jsx', 'ts', 'tsx'],
moduleNameMapper: {
'\\.(css|jpg|png|webp)$': '<rootDir>/test/empty-module.cjs',
'\\.svg$': '<rootDir>/test/svg-file-mock.ts',
// Load path aliases from tsconfig.json
...hq.get('jest', { format: 'array' }),
},
collectCoverageFrom: [
'src/**/*.[jt]s?(x)',
'functions/**/*.[jt]s?(x)',
'!**/src/**/*.stories.[jt]s?(x)',
'!**/node_modules/**',
'!**/.netlify/**',
'!**/src/config/**',
'!**/src/ampli/**',
'!**/__generated__/**',
'!**/*.d.ts',
],
reporters: [
'default',
[
'jest-junit',
{ outputDirectory: 'reports/jest', outputName: 'report.xml' },
],
],
testEnvironment: 'jest-environment-jsdom',
testEnvironmentOptions: {
url: 'http://localhost/',
resources: 'usable',
},
}; |
@kaelig did you tried to add |
That's the first thing I tried, but sadly it didn't solve it :/ |
@kaelig did you solve this? Running into the same issue |
I haven't had time to look into this dependency upgrade. Since 3.0.0 doesn't bring any new features, I've deprioritized it. If anybody finds a workaround, please post here! |
Hey @kaelig, That is a valid approach. v3 is dedicated to bring ESM compatibility. In case you want to give it a try I managed to provide a minimal example with v3 and Jest: https://replit.com/@alexander-heimb/redux-actions-jest#jest.config.js Also a different way would be to use |
Hey @alexander-heimbuch, here's my jest config
The app is running fine but it's giving errors in test, it is giving ![]() @kaelig @markthiessen did you guys find any solution? |
I haven't found any solutions, sorry! |
## Which problem is this PR solving? - This PR upgrades the `redux-actions` package from v2.2.1 to v2.6.5. - The next version released by the redux-actions team is v3, after 2.6.5, but it doesn't support CJS exports so we can't upgrade to that version. - relates to: redux-utilities/redux-actions#390 - Also, v3 doesn't include any new feature, so can be ignored: https://github.com/redux-utilities/redux-actions/releases/tag/v3.0.0 ## Notable addition: Since version 2.5.0, package size has been reduced by up to 50% ## How was this change tested? - locally ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Ansh Goyal <[email protected]>
The new ESM version fails to be imported by TypeScript.
Here's a reproducible comparison:
In the shell, run:
tsc index.ts
The text was updated successfully, but these errors were encountered: