繁体   English   中英

Angular 通用全局导入

[英]Global Import in Angular Universal

我正在尝试将通用添加到我现有的 Angular 项目中。 当作为传统的 angular 项目运行时,一切都很好,但是每当我尝试npm run serve:ssr时,我都会遇到错误。

I'm using the Parse JS SDK in my application ( https://github.com/parse-community/Parse-SDK-JS ) which I'm importing as a global script in my angular.json file:

"architect": {
  "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
      "outputPath": "dist/web/browser",
      "index": "src/index.html",
      "main": "src/main.ts",
      "polyfills": "src/polyfills.ts",
      "tsConfig": "./tsconfig.app.json",
      "inlineStyleLanguage": "scss",
      "assets": [
        "src/favicon.ico",
        "src/assets"
      ],
      "styles": [
        "src/styles.scss"
      ],
      "scripts": [
        "node_modules/parse/dist/parse.js"
      ]
    },

并作为我的 tsconfig 文件中的一种类型:

"compilerOptions": {
  "outDir": "./out-tsc/app",
  "types": ["parse"],

尝试serve:ssr

ReferenceError: Parse is not defined
    at 80478 (/web/dist/web/server/main.js:1:35698)

我正在使用 Angular 14.1.3和 @nguniversal/express-engine 14.1.0

我需要做些什么来在通用中导入这样的全局脚本吗? 其他人在类似情况下会采取什么方法? 我确实发现了这个问题 - https://github.com/angular/universal/issues/1114引用了“这是意料之中的,全局脚本不打算使用当前的 SSR 方法执行”。

这里有什么替代方案? 我非常感谢任何人对此提供的任何指导或建议,谢谢!

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM