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

chore: Vite Bundle Size Action Example Demonstrating Vite Errors with library #7970

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/actions/bundle-size-action/vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
19 changes: 19 additions & 0 deletions .github/actions/bundle-size-action/vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script>
if(global === undefined){
global = window;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

yarn dev initially failed for me, then I changed this to:

		<script>
			// https://docs.amplify.aws/start/getting-started/setup/q/integration/angular#angular-6-support
			window.global = window;
		</script>

Now yarn dev works! But yarn build still fails...

</script>

<script type="module" src="/src/main.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions .github/actions/bundle-size-action/vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "vite",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"aws-amplify": "^3.3.25",
"vue": "^3.0.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.1.5",
"@vue/compiler-sfc": "^3.0.5",
"vite": "^2.1.0"
Comment on lines +14 to +16
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this use latest? I don't know how this project is initialized, so I'm uncertain if these are latest, next, or specifically defined from some external docs.

Copy link
Author

Choose a reason for hiding this comment

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

This is what's configured after a yarn create @vitejs/app

}
}
Binary file not shown.
22 changes: 22 additions & 0 deletions .github/actions/bundle-size-action/vite/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Hello Vue 3 + Vite" />
</template>

<script setup>
import HelloWorld from './components/HelloWorld.vue'

// This starter template is using Vue 3 experimental <script setup> SFCs
// Check out https://github.com/vuejs/rfcs/blob/script-setup-2/active-rfcs/0000-script-setup.md
</script>

<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<h1>{{ msg }}</h1>

<p>
<a href="https://vitejs.dev/guide/features.html" target="_blank">Vite Documentation</a> |
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a>
</p>

<button @click="state.count++">count is: {{ state.count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.
</p>
</template>

<script setup>
import { defineProps, reactive } from 'vue'

defineProps({
msg: String
})

const state = reactive({ count: 0 })
</script>

<style scoped>
a {
color: #42b983;
}
</style>
9 changes: 9 additions & 0 deletions .github/actions/bundle-size-action/vite/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createApp } from 'vue'
import App from './App.vue'



import Amplify, { Auth } from 'aws-amplify';

Amplify.configure({});
createApp(App).mount('#app')
14 changes: 14 additions & 0 deletions .github/actions/bundle-size-action/vite/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
build: {
rollupOptions: {
output: {
intro: 'const global = window;',
},
},
},
});