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

fix(optimizer): ensure the js files in deps won't mark as external #2709

Closed
wants to merge 1 commit into from

Conversation

ci010
Copy link

@ci010 ci010 commented Mar 26, 2021

Description

The current behavior of prebundle (optimizer) will pack all deps in node_modules into chunks, whereas when it hit some js ending with assets ending, like abc.scss.js or xyz.svg.js, vite will treat the js file as external so it won't be correctly bundled.

For example, in office-ui-fabric-react:

// this is from node_modules/office-ui-fabric-react/lib/components/Dropdown/Dropdown.js

var stylesImport = require("./Dropdown.scss");

The stylesImport will be resolved to './Dropdown.scss.js' with external marked, so it's generated like

var stylesImport = require(/* a full path of Dropdown.scss.js */);

We expect that it should be something like

var stylesImport = require_Dropdown_scss(); // this require_Dropdown_scss is the bundled module from ./Dropdown.scss.js

This PR fix this issue.

A similar issue described in #2492

Additional context

I'm not familiar with the testing infra here, and I'm still working with the test.... hopefully I can add a test for this soon.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

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

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Shinigami92 Shinigami92 added p3-minor-bug An edge case that only affects very specific usage (priority) bug labels Mar 26, 2021
@ci010 ci010 marked this pull request as ready for review March 29, 2021 02:45
@ci010 ci010 marked this pull request as draft March 29, 2021 02:47
@aleclarson aleclarson marked this pull request as ready for review October 6, 2021 18:37
@aleclarson
Copy link
Member

Does this have a test case already?

@patak-dev
Copy link
Member

This PR got stalled because of a missing test. And others PR have touched on this area fixing the linked issue #2492:

@ci010 would you check if this is still an issue for you? I think we should close this PR and you can create a new issue with a minimal reproduction if it is still and issue.

@patak-dev
Copy link
Member

Let's close this one in favor of creating a new issue if this problem persists.

@patak-dev patak-dev closed this Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs test p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants