SyntaxError: Cannot use import statement outside a module #7193
Unanswered
Nely-Hartenyan
asked this question in
Q&A
Replies: 1 comment
-
I try #4969 but it doesn't work for me (( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I use "swiper": "^11.0.4". in my react app

When i run test i get this error
my jest.config
`import type { Config } from 'jest';
const config: Config = {
clearMocks: true,
coverageDirectory: './',
coverageReporters: ['cobertura', 'text'],
testEnvironment: 'jsdom',
moduleDirectories: ['node_modules'],
testMatch: [
// "/tests//.[jt]s?(x)",
// "/?(.)+(spec|test).[tj]s?(x)"
'src//(.)@(spec|test).[tj]s?(x)',
],
moduleFileExtensions: ['js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node'],
modulePaths: ['src'],
setupFilesAfterEnv: ['setupTests.ts'],
};
export default config;
`
.bablrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
[
"module-resolver",
{
"alias": {
"@": "./src"
}
}
]
]
}
and tsConfig
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": ".",
"paths": {
"@/app/": ["src/app/"],
"@/pages/": ["src/pages/"],
"@/entities/": ["src/entities/"],
"@/feature/": ["src/feature/"],
"@/shared/": ["src/shared/"],
"@/widgets/": ["src/widgets/"],
"@/": ["src/"]
},
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"types": ["node", "jest", "jest.config.ts", "@testing-library/jest-dom"]
},
"include": ["src/**/*", "config.json", "jest.config.ts"],
"exclude": ["craco.config.ts"],
}
I use FSD, and i the shared/ui index.ts I want to export { Swiper, SwiperSlide } from 'swiper/react'; and then use it
Beta Was this translation helpful? Give feedback.
All reactions