Skip to content

ReferenceError: window is not defined in 0.32.0 #339

Closed
@quisido

Description

@quisido

What happens and why it is wrong

Environment

  • Yarn 3
Versions

The command to use envinfo throws an error, so I'm resorting to copy-paste. All versions are latest.

    "rollup": "^2.75.5",
    "rollup-plugin-typescript2": "^0.32.0",
    "typescript": "^4.7.2"

The error resides here:

if (typeof commonjsRequire === "function") {
  try {
    lodash = {
      clone: require("lodash/clone"),
      constant: require("lodash/constant"),
      each: require("lodash/each"),
      filter: require("lodash/filter"),
      has:  require("lodash/has"),
      isArray: require("lodash/isArray"),
      isEmpty: require("lodash/isEmpty"),
      isFunction: require("lodash/isFunction"),
      isUndefined: require("lodash/isUndefined"),
      keys: require("lodash/keys"),
      map: require("lodash/map"),
      reduce: require("lodash/reduce"),
      size: require("lodash/size"),
      transform: require("lodash/transform"),
      union: require("lodash/union"),
      values: require("lodash/values")
    };
  } catch (e) {
    // continue regardless of error
  }
}

if (!lodash) {
  lodash = window._;
}

The line saying to use window._ throws an error because window does not exist in the Node environment.

This is newly introduced in 0.32.0. Reverting to 0.31.0 fixes this.

Metadata

Metadata

Assignees

Labels

kind: regressionSpecific type of bug -- past behavior that worked is now brokenproblem: removed issue templateOP removed the issue template without good causescope: dependenciesIssues or PRs about updating a dependencyscope: upstreamIssue in upstream dependencysolution: workaround availableThere is a workaround available for this issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions