简体   繁体   English

使用 Typescript 进行 Cypress 测试中的动态导入:ChunkLoadError:加载块 1 失败

[英]Dynamic imports in Cypress tests using Typescript: ChunkLoadError: Loading chunk 1 failed

I'm trying to use dynamic imports in my cypress tests, like this const inputModule = await import('../../__tests__/testCases/baseInput');我正在尝试在我的 cypress 测试中使用动态导入,例如 const inputModule = await import('../../__tests__/testCases/baseInput');

But I'm getting this error: ChunkLoadError: Loading chunk 1 failed.但我收到此错误:ChunkLoadError:加载块 1 失败。 (missing: http://localhost:3000/__cypress/iframes/integration/1.cases.spec.ts ) (缺失: http://localhost:3000/__cypress/iframes/integration/1.cases.spec.ts

This is my webpack config:这是我的 webpack 配置:


module.exports = on => {
  const options = {
    webpackOptions: {
      resolve: {
        extensions: ['.ts', '.tsx', '.js'],
      },
      module: {
        rules: [
          {
            test: /\.tsx?$/,
            loader: 'ts-loader',
            options: { transpileOnly: true },
          },
        ],
      },
    },
  };
  on('file:preprocessor', wp(options));
};

And this is my tsconfig.json这是我的 tsconfig.json

{
  "extends": "../tsconfig.json",
  "include": ["cypress/**/*.ts", "**/*.ts", "**/*.js"],
  "exclude": [],
}

I had to add this to my tsconfig.json :我不得不将此添加到我的tsconfig.json

"compilerOptions": {
    "module": "CommonJS",
  }

and this to my webpack config这对我的 webpack 配置

output: {
        fileName: 'bundle.js',
        chunkFileName: '[name].bundle.js',
      }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Webpack 代码拆分:ChunkLoadError - 加载块 X 失败,但块存在 - Webpack code splitting: ChunkLoadError - Loading chunk X failed, but the chunk exists Uncaught SyntaxError: Unexpected token &#39;&lt;&#39; and ChunkLoadError: Loading chunk 16 failed - Uncaught SyntaxError: Unexpected token '<' and ChunkLoadError: Loading chunk 16 failed Fusion Charts Zoomline React 错误:ChunkLoadError:加载块 6 失败 - Fusion Charts Zoomline React Error: ChunkLoadError: Loading chunk 6 failed Vercel Next js Uncaught (in promise) ChunkLoadError: Loading chunk 0 failed - Vercel Next js Uncaught (in promise) ChunkLoadError: Loading chunk 0 failed Angular Uncaught (in promise): ChunkLoadError: Loading chunk XXXfailed - Angular Uncaught (in promise): ChunkLoadError: Loading chunk XXXfailed 如何解决 ChunkLoadError: Loading hot update chunk second_app failed in webpack 5? - How to solve ChunkLoadError: Loading hot update chunk second_app failed in webpack 5? Laravel Vuejs 未捕获(承诺)ChunkLoadError:加载块博客组件失败 - Laravel Vuejs Uncaught (in promise) ChunkLoadError: Loading chunk blogs-component failed ChunkLoadError:加载块 node_modules_next_dist_client_dev_noop_js 失败 - ChunkLoadError: Loading chunk node_modules_next_dist_client_dev_noop_js failed 使用动态导入时将 Webpack 块 url 作为字符串获取 - Get Webpack chunk url as string when using dynamic imports 在 typescript 中使用动态导入时的性能 - Performance when using dynamic imports in typescript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM