Angular polyfill.ts 文件帮助。 polyfill 代码去哪儿了?处理它需要什么?

Angular polyfill.ts file help. Where does the polyfill code go? and what is required to handle it?

所以我有一个 angular 项目出错了,需要一些 'polyfilling'。由于 Angular 不允许在不导出的情况下编辑 webpack.config.js 文件,我认为预期的目的是让开发人员编辑 polyfill.ts 文件。现在 src 文件夹中的 polyfill.ts 可以识别关键字 'resolve',因为它是以这种方式从 dns 导入的:

import {resolve} from 'dns';

这是 Angular 的典型特征。但是来自 Angular 的错误消息表明这个导入的 resolve 应该有方法 .fallback 而它没有。

这是 polyfill.ts 的代码图片:

这是前面提到的 Angular 错误的片段:

有谁知道 Angular 期望将此代码放在哪里? polyfill.ts 文件是否还有其他用途,而不是我在 post 中假设的用途?实际处理 polyfill 是否需要更健壮的代码?我假设它都会在这里,否则为什么将文件放在名为 polyfill 的 src 文件夹中,整个项目都可以看到它?如果这个问题看起来太宽泛,我深表歉意,任何和所有批评/建议都将受到赞赏,因为我在黑暗中笨手笨脚。

下面是 Angular 生成的完整错误:

 $ ng serve
    Your global Angular CLI version (13.0.1) is greater than your local version (12.2.13). The local Angular CLI version is used.
    
    To disable this warning use "ng config -g cli.warnings.versionMismatch false".
    - Generating browser application bundles (phase: setup)...
    √ Browser application bundle generation complete.
    
    Initial Chunk Files   | Names         |      Size
    vendor.js             | vendor        |   6.48 MB
    polyfills.js          | polyfills     | 510.73 kB
    styles.css, styles.js | styles        | 383.69 kB
    main.js               | main          |  81.66 kB
    runtime.js            | runtime       |   6.69 kB
    
    | Initial Total |   7.44 MB
    
    Build at: 2021-11-26T16:15:03.838Z - Hash: b77d276f8b953e0e2990 - Time: 10837ms
    
    ./node_modules/sequelize/lib/dialects/abstract/connection-manager.js:82:15-63 - Warning: Critical dependency: the request of a dependency is an expression
    
    ./node_modules/sequelize/lib/dialects/abstract/connection-manager.js:89:13-32 - Warning: Critical dependency: the request of a dependency is an expression
    
    
    
    ./node_modules/sequelize/lib/dialects/mssql/query-generator.js:8:20-49 - Error: Module not found: Error: Can't resolve 'crypto' in 'C:\again\software-engineering-team-project-fourtothefloor\node_modules\sequelize\lib\dialects\mssql'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
            - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
            - install 'crypto-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
            resolve.fallback: { "crypto": false }
    
    ./node_modules/sequelize/lib/dialects/postgres/hstore.js:3:15-35 - Error: Module not found: Error: Can't resolve 'pg-hstore' in 'C:\again\software-engineering-team-project-fourtothefloor\node_modules\sequelize\lib\dialects\postgres'
    
    ./node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:5:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\again\software-engineering-team-project-fourtothefloor\node_modules\sequelize\lib\dialects\sqlite'
    
    ./node_modules/sequelize/lib/model.js:5:15-32 - Error: Module not found: Error: Can't resolve 'assert' in 'C:\again\software-engineering-team-project-fourtothefloor\node_modules\sequelize\lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
            - add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
            - install 'assert'
    If you don't want to include a polyfill, you can use an empty module like this:
            resolve.fallback: { "assert": false }
    
    
    
    ** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
    
    
    × Failed to compile.

结合这个post:

webpack 5 angular polyfill for node.js crypto-js

对于这个错误,不需要 polyfill。只需编辑 angular.json 和 tsconfig.json 文件。

非 polyfilling 错误 spring 由于没有规范 server/client 设置。