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

instantiateModule @ ssrModuleLoader fails to import #3856

Closed
6 tasks done
eunjae-lee opened this issue Jun 18, 2021 · 1 comment · Fixed by #3869
Closed
6 tasks done

instantiateModule @ ssrModuleLoader fails to import #3856

eunjae-lee opened this issue Jun 18, 2021 · 1 comment · Fixed by #3869

Comments

@eunjae-lee
Copy link

Describe the bug

instantiateModule in ssrModuleLoader.ts tries to load a library that I'm working on, and it fails. That error happens lots of times across many files in the library.

The library works fine with vite when it's not SSR. It's failing only with SSR.

5:15:47 PM [vite] Error when evaluating SSR module /node_modules/vue-instantsearch/dist/vue3/es/src/components/InstantSearchSsr.js:
ReferenceError: e is not defined
    at Module.s (../../../../../src/util/createInstantSearchComponent.js:80:4)
    at ../../../../../src/components/InstantSearchSsr.js:9:8
    at instantiateModule (/Users/eunjaelee/sandbox/vue3-ssr-vis/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:68693:166)

I'm not so sure but from my observation, let's say we have this:

// /node_modules/vue-instantsearch/.../a.js
import { something1 as e } from 'else1';
import { fn } from './b.js';

and

// /node_modules/vue-instantsearch/.../b.js
import { something2 as e } from 'else2';

When a.js is importing b.js and two files both have something called e, then it fails.

Reproduction

  1. Clone the repo
  2. yarn install && yarn run dev
  3. open http://localhost:3000
  4. You'll see the error.

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 1.03 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.19.0 - ~/.nvm/versions/node/v12.19.0/bin/node
    Yarn: 1.16.0 - /usr/local/Cellar/yvm/3.6.7/shim/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v12.19.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 91.0.4472.114
    Safari: 14.1.1
  npmPackages:
    @vitejs/plugin-vue: 1.2.3 => 1.2.3 
    vite: 2.3.7 => 2.3.7 

Used package manager: reproduced in both [email protected] and [email protected]

Logs

$ node server
http://localhost:3000
5:24:28 PM [vite] Error when evaluating SSR module /node_modules/vue-instantsearch/dist/vue3/es/src/components/InstantSearchSsr.js:
ReferenceError: e is not defined
    at Module.s (../../../../../src/util/createInstantSearchComponent.js:80:4)
    at ../../../../../src/components/InstantSearchSsr.js:9:8
    at instantiateModule (/Users/eunjaelee/sandbox/vue3-ssr-vis/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:68693:166)
ReferenceError: e is not defined
    at Module.s (../../../../../src/util/createInstantSearchComponent.js:80:4)
    at ../../../../../src/components/InstantSearchSsr.js:9:8
    at instantiateModule (/Users/eunjaelee/sandbox/vue3-ssr-vis/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:68693:166)

... and it goes on like the above

What I tried with this log is,

  • InstantSearchSsr.js is being loaded and it seems to be failed while it was importing its dependency createInstantSearchComponent.js
  • So I opened the both files from node_modules/.... path.

InstantSearchSsr.js looks like this:

import { isVue3 as t, h as s } from "vue-demi";
import { createInstantSearchComponent as n } from "../util/createInstantSearchComponent.js";
...

createInstantSearchComponent.js looks like this:

import { createSuitMixin as n } from "../mixins/suit.js";
import { version as t, isVue3 as e } from "vue-demi";
import { version as a } from "../../package.json.js";
import { _objectSpread as i } from "./polyfills.js";

polyfills.js looks like this:

function e(e) {
  ...
}

export { e as _objectSpread };

So, why does it say ReferenceError: e is not defined? I don't know, but I see the e in createInstantSearchComponent.js and polyfills.js.

I renamed the function e in polyfills.js, so that

function e1(e) {
  ...
}

export { e1 as _objectSpread };

Then I ran rm -rf node_modules/.vite && yarn dev, and it no longer gives me the error. It still gives me the similar errors but in other files. I kept renaming stuff like this, and finally got it working with no errors.

I don't know why this same name across different files make this errors.


Before submitting the issue, please make sure you do the following

@github-actions
Copy link

This issue gets locked because it has been closed for more than 14 days.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 13, 2021
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