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

feat: dynamic import retry plugin [KM-865] #2

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

2eha0
Copy link

@2eha0 2eha0 commented Jan 7, 2025

Summary

  • add dynamic import retry plugin
  • add e2e tests and vitest settings
  • modified CI to support playwright caches

KM-865

@2eha0 2eha0 force-pushed the feat/dynmamic-import-retry branch 7 times, most recently from a527f90 to 77c17e6 Compare January 7, 2025 08:30
@2eha0 2eha0 force-pushed the feat/dynmamic-import-retry branch from 77c17e6 to 9ddda00 Compare January 7, 2025 08:37
Copy link
Member

@adamdehaven adamdehaven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left an initial review; the biggest issue is please back out the changes turning this into a mono repo.

Separately, it would be great if you could please extensively comment the code so that maintenance and future updates are easier.

package.json Outdated
Comment on lines 11 to 12
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I'm not sure I understand the multiple test commands here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug-* are not necessary, removed

playground/vitestGlobalSetup.ts Show resolved Hide resolved
@@ -0,0 +1,350 @@
import type * as http from 'node:http'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I believe most of this was taken from one of the existing vite repos. Are we actually using the entirety of the config or is there any unneeded code here for our purpose?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed most of code that I thought they were not necessary for us.

@@ -0,0 +1,24 @@
# Logs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is there a reason this ignore logic can't be in the root .gitignore? (We wouldn't want to ignore .vscode/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


export const workspaceRoot = resolve(__dirname, '../')

export const isBuild = !!process.env.VITE_TEST_BUILD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain the env variables used in the file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments added

Comment on lines 1 to 19
{
"name": "@kong-vite-plugin/vue",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.5.13",
"vue-router": "^4.5.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"@vue/tsconfig": "^0.7.0",
"vue-tsc": "^2.2.0"
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: why does the playground need its own package.json file? This isn't a monorepo. Please move dependencies to the root

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create multiple projects under the playground folder, package.json for each one is necessary, otherwise, how can we manually run those demo projects from the root level?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please write up how you envision the testing working?

I’m not sure it makes sense to have fully-standalone applications for testing purposes.

If we need to change to a mono repository then I’d first want to restructure things before merging this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If each package is independent and needs an entire app sandbox I’d almost rather delete this repository and just utilize public-ui-components instead; it’s already set up and would essentially just need a different build command.

For dependencies in the current structure, playground dependencies would be devDependencies in the root package.json

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial thought was that we might need multiple applications to test different cases, similar to https://github.com/vitejs/vite-plugin-vue/tree/main/playground.

However, we can start simple by writing all use cases in a single project. If more complex scenarios arise, we can refactor it into a monorepo as needed.

@@ -0,0 +1,24 @@
{
"compilerOptions": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why does the playground need its own tsconfig? Can it just extend the one from the root?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 1 to 2
packages:
- 'playground/**'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: this should not be a monorepo, please remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Comment on lines 7 to 13
/*
Copyright 2024 Carl-Erik Kopseng

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
Copy link
Member

@adamdehaven adamdehaven Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a requirement of an external lib? If yes, can you please add a link to the source?

Also, could this be extracted into its own file and imported where needed rather than inlined into our code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link added.

No, the code in this function shouldn't have external references, I put detailed reason in comments.

Comment on lines 77 to 83
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV

- name: Cache Playwright's binary
uses: actions/cache@v4
with:
key: playwright-bin-v1
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: It would be preferred to give the step an id, output via $GITHUB_OUTPUT, and then reference the step output below where needed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@CLAassistant
Copy link

CLAassistant commented Jan 8, 2025

CLA assistant check
All committers have signed the CLA.

@2eha0 2eha0 force-pushed the feat/dynmamic-import-retry branch from c0a326e to 73dc74e Compare January 9, 2025 09:41
Copy link
Member

@adamdehaven adamdehaven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some initial feedback.

There is a large lack of comments in the code that would be helpful for review. Please thoroughly comment the code.

id: playwright-cache
uses: actions/cache@v4
with:
key: playwright-bin-v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we tie the cache key here to a dynamic string that includes the playwright dependency version from package.json?

@@ -20,3 +20,6 @@ dist

# Local History
.history

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe some additional playwright artifact paths will need to be added

@@ -0,0 +1 @@
/// <reference types="vite/client" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can remove this file and reference the types in the tsConfig

"baseUrl": ".",
"outDir": "dist",
"declaration": false,
"declarationDir":null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"declarationDir":null
"declarationDir": null

const identity = (e: any) => e
const retry = createDynamicImportWithRetry(options.retries)

/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part of this file is from the external reference? Can we move the copyright and the code into a separate file, add a URL from where the code was sourced from, and import here where needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants