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

class missing #3084

Closed
MQYForverT opened this issue Apr 22, 2021 · 7 comments · Fixed by #3144
Closed

class missing #3084

MQYForverT opened this issue Apr 22, 2021 · 7 comments · Fixed by #3144

Comments

@MQYForverT
Copy link

Use glob to dynamically add routes. After packaging, it is found that the class inside the component is not packaged

@github-actions
Copy link

Hello @MQYForverT. Please provide a online reproduction by codesandbox or a minimal GitHub repository. Issues labeled by need reproduction will be closed if no activities in 3 days.

@kwesterfeld2
Copy link

After upgrading to 2.2.1 this week a whole bunch of CSS related to my application disappeared, and we had to rollback to 2.1.5. This looks like a similar issue: some of our CSS got bundled, but much of it just didn't get included any more.

@patak-dev
Copy link
Member

@kwesterfeld2 could you try to create reproduction of this issue?

@MQYForverT
Copy link
Author

MQYForverT commented Apr 22, 2021

@ kwesterfeld2您可以尝试复制此问题吗?

I don't have a link for you to reproduce, but I can describe the scene for you,Or you can download demo and try it yourself
https://github.com/MQYForverT/vue-next-admin.git

It is to define a static route, add routes to the router, and the typed packet style is normal. If you use glob to dynamically introduce routes, add routes to the router, and the typed packet style will be lost

I'm sure! Using glob to dynamically introduce routes, the generated route table is exactly the same as the statically defined route table!

@wuyiw
Copy link

wuyiw commented Apr 22, 2021

i have the same issue and here's a reproduction:
https://github.com/wuyiw/vite-preload-dep
both a.jsx and b.jsx import common.module.less, and they are dynamically imported in router.
in dev mode thing goes well, but in build mode, below code is generated:

const a = () => __vitePreload(() => __import__("./a.9ce71214.js"), true ? ["/assets/a.9ce71214.js","/assets/common.module.4b52b9d5.js","/assets/common.module.816a14f3.css","/assets/vendor.c97e27de.js"] : void 0);
const b = () => __vitePreload(() => __import__("./b.eebe1df7.js"), true ? void 0 : void 0);

a.jsx has correct dependencies while b.jsx doesn't, so if you type /( default to a ) in browser and enter, then navigate to /b, it's fine, but if you type /b in browser and enter, the style is missing.
only the first delcared dynamic import gets correct dependencies. if you swap the order in router.js, you must enter /b first to get style loaded.

patak-dev added a commit that referenced this issue Apr 25, 2021
@patak-dev
Copy link
Member

@wuyiw @MQYForverT @kwesterfeld2 the fix was released in Vite v2.2.3, you should be able to update to it in your projects

@kwesterfeld2
Copy link

@patak-js thanks for the mention, I upgraded and I can confirm this issue is fixed for me.

TobiasMelen pushed a commit to TobiasMelen/vite that referenced this issue May 3, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 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.

6 participants