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(plugin-legacy): respect custom filenames formats, fix #2356 #2641

Merged
merged 3 commits into from May 21, 2021
Merged

fix(plugin-legacy): respect custom filenames formats, fix #2356 #2641

merged 3 commits into from May 21, 2021

Conversation

anncwb
Copy link
Contributor

@anncwb anncwb commented Mar 22, 2021

fix #2356

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.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Description

Additional context

@patak-dev
Copy link
Member

@anncwb this looks good, thanks!

Would it be possible to add a test for this feature?

@anncwb
Copy link
Contributor Author

anncwb commented Mar 22, 2021

@anncwb this looks good, thanks!

Would it be possible to add a test for this feature?

For plugin-legacy, I did not expect good test cases. Only part of the playground example can be added.

@Shinigami92 Shinigami92 added p3-minor-bug An edge case that only affects very specific usage (priority) bug labels Mar 22, 2021
@terry-au
Copy link

Not sure how to test cases where a custom bundle output is defined. Is it possible to have different configurations between tests? In any case, I've written a test to ensure the default chunk naming setup works as expected.

From 4e014ceabce1535cbb7860e2a0dfcee3b679e685 Mon Sep 17 00:00:00 2001
From: Terry Lewis <terry-au@users.noreply.github.com>
Date: Fri, 21 May 2021 09:34:07 +1000
Subject: [PATCH] test(playground): add test for legacy bundle name generation

---
 .../legacy/__tests__/legacy.spec.ts           | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/packages/playground/legacy/__tests__/legacy.spec.ts b/packages/playground/legacy/__tests__/legacy.spec.ts
index 0a9a2148..008a07eb 100644
--- a/packages/playground/legacy/__tests__/legacy.spec.ts
+++ b/packages/playground/legacy/__tests__/legacy.spec.ts
@@ -12,3 +12,22 @@ test('import.meta.env.LEGACY', async () => {
 test('transpiles down iterators correctly', async () => {
   expect(await page.textContent('#iterators')).toMatch('hello')
 })
+
+test('generates chunk names with hashes', async () => {
+  // we're only supporting legacy in prod,
+  // so we skip this test when isBuild is false
+  if (!isBuild) return
+
+  const scriptTags = await page.$$('//html/body/script')
+  expect(scriptTags).toHaveLength(3)
+
+  const [, polyfills, systemJSScriptSrc] = scriptTags
+
+  expect(await polyfills.getAttribute('src')).toEqual(
+    expect.stringMatching(/^\/assets\/polyfills-legacy.[a-zA-Z0-9]+.js$/)
+  )
+
+  expect(await systemJSScriptSrc.getAttribute('data-src')).toEqual(
+    expect.stringMatching(/^\/assets\/index-legacy.[a-zA-Z0-9]+.js$/)
+  )
+})
-- 
2.30.1 (Apple Git-130)

@patak-dev patak-dev changed the title fix(plugin-legacy): respect custom filenames format output fix #2356 fix(plugin-legacy): respect custom filenames formats, fix #2356 May 21, 2021
@patak-dev patak-dev merged commit d852731 into vitejs:main May 21, 2021
fi3ework pushed a commit to fi3ework/vite that referenced this pull request May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) plugin: legacy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Legacy build ignores custom filenames
6 participants