rollup / plugins

🍣 The one-stop shop for official Rollup plugins
MIT License
3.57k stars 568 forks source link

fix: Cannot read properties of undefined (reading 'ssr') #1654

Open dylan-chong opened 6 months ago

dylan-chong commented 6 months ago

Fixes this while running vite 4.x.x with 25.0.7 of the commonjs rollup plugin here

12:25:55 AM [vite] Internal server error: Cannot read properties of undefined (reading 'ssr')
  Plugin: commonjs
  File: /home/dylanchong/partly-development/partly-2/packages/libs/dbids/build/index.js
      at load (file:///home/dylanchong/partly-development/partly-2/node_modules/.pnpm/vite@4.5.1_@types+node@17.0.45+sass@1.30.0/node_modules/vite/dist/node/chunks/dep-68d1a114.js:44006:78)
      at analyzeRequiredModule (/home/dylanchong/partly-development/partly-2/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.20.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:694:13)
      at /home/dylanchong/partly-development/partly-2/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.20.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:802:19
      at async Promise.all (index 1)
      at async /home/dylanchong/partly-development/partly-2/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.20.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:781:32
      at async rewriteRequireExpressionsAndGetImportBlock (/home/dylanchong/partly-development/partly-2/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.20.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:1358:28)
      at async transformCommonjs (/home/dylanchong/partly-development/partly-2/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.20.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:1932:23)
      at async Object.transform (file:///home/dylanchong/partly-development/partly-2/node_modules/.pnpm/vite@4.5.1_@types+node@17.0.45+sass@1.30.0/node_modules/vite/dist/node/chunks/dep-68d1a114.js:44352:30)
      at async loadAndTransform (file:///home/dylanchong/partly-development/partly-2/node_modules/.pnpm/vite@4.5.1_@types+node@17.0.45+sass@1.30.0/node_modules/vite/dist/node/chunks/dep-68d1a114.js:55026:29)

In vite's code, this is the line that fails due to this being undefined

        async load(options) {
            // We may not have added this to our module graph yet, so ensure it exists
            await moduleGraph?.ensureEntryFromUrl(unwrapId(options.id), this.ssr);

Rollup Plugin Name: {name}

This PR contains:

Are tests included?

Breaking Changes?

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

shellscape commented 5 months ago

Thanks for the PR. We'll need a regression test for this before we can merge, however. Please add a test when you have the chance to.

It also looks like your branch might be a good bit behind master. Please rebase as well.

FANZHETWO commented 3 months ago

Hey, boss, did you get this resolved? So did I