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

update to credentialless, bump version, load environment #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?

.env
6 changes: 4 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import './style.css'
import { WebContainer } from '@webcontainer/api';
import { files } from './files';

Object.assign(window, WEBCONTAINER_STARTER_ENV);

/** @type {import('@webcontainer/api').WebContainer} */
let webcontainerInstance;

Expand All @@ -12,7 +14,7 @@ window.addEventListener('load', async () => {
});

// Call only once
webcontainerInstance = await WebContainer.boot();
webcontainerInstance = await WebContainer.boot({ coep: 'credentialless'});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

⭐ New default

await webcontainerInstance.mount(files);

const exitCode = await installDependencies();
Expand Down Expand Up @@ -68,4 +70,4 @@ document.querySelector('#app').innerHTML = `
const iframeEl = document.querySelector('iframe');

/** @type {HTMLTextAreaElement | null} */
const textareaEl = document.querySelector('textarea');
const textareaEl = document.querySelector('textarea');
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"vite": "^4.1.0"
},
"dependencies": {
"@webcontainer/api": "^1.1.3"
"@webcontainer/api": "^1.1.8"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

⭐ New version

}
}
11 changes: 7 additions & 4 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';

export default defineConfig({
export default defineConfig(({ mode }) => ({
define: {
WEBCONTAINER_STARTER_ENV: JSON.stringify(loadEnv(mode, process.cwd(), 'WEBCONTAINER_'))
},
server: {
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Embedder-Policy': 'credentialless',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

⭐ New default

'Cross-Origin-Opener-Policy': 'same-origin',
},
},
});
}));