Skip to content

Commit

Permalink
chore(developer): add react/parcel 🗼
Browse files Browse the repository at this point in the history
- Glued in now. Or at least duct taped.
- parcel builds into build/ which is picked up by the app

Fixes: #12789
  • Loading branch information
srl295 committed Dec 5, 2024
1 parent 6c62ecc commit 8f354f7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
9 changes: 8 additions & 1 deletion developer/src/vscode-plugin/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import React from 'react';
import './App.css';

let a : number = 3;

function count() : number {
return (++a);
}

function App() {
return (
<div className="App">
Hello world!
Hello world!! 2+2 = ${count()}
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion developer/src/vscode-plugin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ builder_describe_outputs \
builder_parse "$@"

function do_clean() {
rm -rf ./out/ ./tsconfig.tsbuildinfo .vscode-test
rm -rf ./out/ ./tsconfig.tsbuildinfo .vscode-test ./build .parcel-cache
}

function do_configure() {
Expand Down
4 changes: 2 additions & 2 deletions developer/src/vscode-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"pretest": "npm run compile && npm run build && npm run lint",
"lint": "eslint src",
"test": "vscode-test",
"build": "parcel build --target=default --cache-dir=.parcel-cache"
"build": "parcel build --target=default --cache-dir=.parcel-cache --no-content-hash"
},
"devDependencies": {
"@types/mocha": "^10.0.0",
Expand All @@ -69,10 +69,10 @@
"@keymanapp/kmc-kmn": "file:../kmc-kmn",
"@keymanapp/kmc-ldml": "file:../kmc-ldml",
"@keymanapp/kmc-package": "file:../kmc-package",
"process": "^0.11.10",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"browserslist": "> 0.5%, last 2 versions, not dead",
"targets": {
"default": {
"source": "app/index.html",
Expand Down
14 changes: 5 additions & 9 deletions developer/src/vscode-plugin/src/ldmleditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export class LdmlEditorProvider implements vscode.CustomTextEditorProvider {

const { webview } = webviewPanel;

const styleMainUri = webview.asWebviewUri(vscode.Uri.joinPath(this.context.extensionUri, 'media', 'ldmleditor.css'));
// const manifest = webview.asWebviewUri(vscode.Uri.joinPath(this.context.extensionUri, 'build', 'asset-manifest.json'));
const mainScript = webview.asWebviewUri(vscode.Uri.joinPath(this.context.extensionUri, 'build', 'main.js'));
// these are fixed IDs as parcel is set to not do content hashing
const styleUri = webview.asWebviewUri(vscode.Uri.joinPath(this.context.extensionUri, 'build', 'index.89a9d63e.css'));
const scriptUri = webview.asWebviewUri(vscode.Uri.joinPath(this.context.extensionUri, 'build', 'index.2f8490e0.js'));

const nonce = crypto.randomUUID().toString();

Expand All @@ -113,14 +113,13 @@ export class LdmlEditorProvider implements vscode.CustomTextEditorProvider {
<head>
<meta charset="UTF-8">
<!--
Use a content security policy to only allow loading images from https or from our extension directory,
and only allow scripts that have a specific nonce.
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src ${webview.cspSource}; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
<link href="${styleMainUri}" rel="stylesheet" />
<link href="${styleUri}" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand All @@ -129,10 +128,7 @@ export class LdmlEditorProvider implements vscode.CustomTextEditorProvider {
<body>
<noscript>JavaScript is required for this application…</noscript>
<div id="root"></div>
<!-- <h1>Hello, World! </h1>
<pre>${document.getText().replaceAll('<', '&lt;').trim()}</pre>
-->
<script nonce="${nonce}" src="${mainScript}"></script>
<script nonce="${nonce}" src="${scriptUri}"></script>
</body>
</html>
`.trim();
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

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

0 comments on commit 8f354f7

Please sign in to comment.