Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isSelfAccepting of undefined in Vite 2.9.7 SSR #7992

Closed
7 tasks done
saurabhdaware opened this issue May 2, 2022 · 1 comment · Fixed by #7993
Closed
7 tasks done

isSelfAccepting of undefined in Vite 2.9.7 SSR #7992

saurabhdaware opened this issue May 2, 2022 · 1 comment · Fixed by #7993

Comments

@saurabhdaware
Copy link
Contributor

Describe the bug

After 2.9.7, Vite started throwing isSelfAccepting of undefined error.

It seems to happen specifically in the case where we pass inlined css through vite.transformIndexHtml.

Also, before facing this issue, I am also facing #6859 (comment) (which I fixed by adding a random file name to "main" property of package.json (seem hacky))

So this issue could be a side-effect of that issue.

Reproduction

https://stackblitz.com/edit/github-12zodn-gvvydc?file=server.js&terminal=dev

System Info

System:
    OS: macOS 11.4
    CPU: (8) x64 Apple M1
    Memory: 26.97 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.5.0 - ~/.nvm/versions/node/v16.5.0/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 7.19.1 - ~/.nvm/versions/node/v16.5.0/bin/npm
  Browsers:
    Brave Browser: 97.1.34.80
    Chrome: 100.0.4896.127
    Safari: 14.1.1

Used Package Manager

npm

Logs

TypeError: Cannot set properties of undefined (setting 'isSelfAccepting')
    at TransformContext.transform (/home/projects/github-12zodn-gvvydc/node_modules/vite/dist/node/chunks/dep-88bd5805.js:56775:48)
    at async Object.transform (/home/projects/github-12zodn-gvvydc/node_modules/vite/dist/node/chunks/dep-88bd5805.js:38911:30)
    at async eval (/home/projects/github-12zodn-gvvydc/node_modules/vite/dist/node/chunks/dep-88bd5805.js:56245:24)
    at async Promise.all (index 0)
    at async devHtmlHook (/home/projects/github-12zodn-gvvydc/node_modules/vite/dist/node/chunks/dep-88bd5805.js:56240:5)
    at async applyHtmlTransforms (/home/projects/github-12zodn-gvvydc/node_modules/vite/dist/node/chunks/dep-88bd5805.js:29471:21)
    at async eval (/home/projects/github-12zodn-gvvydc/server.js:46:18) {
  plugin: 'vite:import-analysis',
  id: '/home/projects/github-12zodn-gvvydc?html-proxy&0.css',
  pluginCode: '\n      body {\n        background-color: red;\n      }\n    '
}

Validations

@saurabhdaware
Copy link
Contributor Author

saurabhdaware commented May 2, 2022

I did some debugging in repo and it seems to be coming from here-

importerModule.isSelfAccepting = false

Adding a if (importerModule) fixed the issue however there is this comment on the line above which I am not sure if stands true in my case since it does happen to be undefined-

// since we are already in the transform phase of the importer, it must
// have been loaded so its entry is guaranteed in the module graph.
const importerModule = moduleGraph.getModuleById(importer)!

If this is the fix, I'll be happy to send a PR Sent the PR with this change :D

@github-actions github-actions bot locked and limited conversation to collaborators May 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant