Skip to content

Commit a101037

Browse files
Revert "Vite and vitest. Pin versions. More strict npmrc"
This reverts commit 3f63219.
1 parent 3f63219 commit a101037

File tree

16 files changed

+4550
-919
lines changed

16 files changed

+4550
-919
lines changed

ui/extensions/translation-and-context/.npmrc

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
"@babel/preset-env",
5+
{
6+
targets: {
7+
node: "current",
8+
},
9+
},
10+
],
11+
],
12+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const esbuild = require("esbuild");
2+
const path = require("path");
3+
const fs = require("fs");
4+
5+
// Build configuration
6+
esbuild
7+
.build({
8+
entryPoints: [path.join(__dirname, "src", "app.js")],
9+
bundle: true,
10+
outfile: path.join(__dirname, "dist", "app.js"),
11+
format: "esm", // Keep as ES modules since we're using import maps for Foundry JS
12+
minify: true,
13+
sourcemap: true,
14+
external: ["@crowdstrike/foundry-js"], // Don't bundle this as it's provided via import maps
15+
plugins: [
16+
// Add any plugins if needed in the future
17+
],
18+
})
19+
.catch((error) => {
20+
console.error("Build failed:", error);
21+
process.exit(1);
22+
});
23+
24+
// Copy index.html without modification
25+
const srcHtmlPath = path.join(__dirname, "src", "index.html");
26+
const distHtmlPath = path.join(__dirname, "dist", "index.html");
27+
28+
// Copy the HTML file to dist directory
29+
fs.copyFile(srcHtmlPath, distHtmlPath, (err) => {
30+
if (err) {
31+
console.error("Error copying index.html to dist:", err);
32+
return;
33+
}
34+
console.log("index.html copied to dist/ successfully");
35+
});

ui/extensions/translation-and-context/dist/app.js

Lines changed: 28 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/extensions/translation-and-context/dist/app.js.map

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/extensions/translation-and-context/dist/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,25 @@
99
}
1010
</style>
1111

12+
<script type="importmap">
13+
{
14+
"imports": {
15+
"@crowdstrike/foundry-js": "https://assets.foundry.crowdstrike.com/[email protected]/index.js"
16+
}
17+
}
18+
</script>
19+
1220
<link
1321
rel="stylesheet"
1422
href="https://assets.foundry.crowdstrike.com/[email protected]/toucan.css"
1523
/>
16-
<script type="module" crossorigin src="/app.js"></script>
1724
</head>
1825

1926
<body>
2027
<div class="bg-basement flex flex-col gap-4 p-4">
2128
<div id="translationSlot" class="bg-basement flex flex-col gap-4"></div>
2229
<div id="contextSlot" class="bg-basement flex flex-col gap-4"></div>
2330
</div>
31+
<script src="./app.js" type="module"></script>
2432
</body>
2533
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
transform: {
3+
"^.+\\.jsx?$": "babel-jest",
4+
},
5+
testEnvironment: "jsdom",
6+
moduleFileExtensions: ["js", "json"],
7+
testMatch: ["**/__tests__/**/*.js", "**/?(*.)+(spec|test).js"],
8+
transformIgnorePatterns: ["/node_modules/(?!(@crowdstrike/foundry-js)/)"],
9+
setupFilesAfterEnv: ["./jest.setup.js"],
10+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Mock DOM elements that our code interacts with
2+
document.getElementById = jest.fn(() => ({
3+
innerHTML: "",
4+
addEventListener: jest.fn(),
5+
}));
6+
7+
// Mock for navigator.language
8+
Object.defineProperty(navigator, "language", {
9+
get: function () {
10+
return "en-US";
11+
},
12+
});
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
{
22
"name": "translation-and-context",
33
"version": "1.0.0",
4-
"type": "module",
54
"main": "index.js",
65
"private": true,
76
"scripts": {
8-
"build": "vite build",
9-
"test": "vitest run",
10-
"test:watch": "vitest",
11-
"dev": "vite",
12-
"preview": "vite preview"
7+
"test": "jest",
8+
"test:watch": "jest --watch --silent=false",
9+
"test:coverage": "jest --coverage",
10+
"build": "node build.js"
1311
},
1412
"keywords": [],
1513
"author": "",
1614
"license": "MIT",
1715
"description": "",
1816
"dependencies": {
19-
"@crowdstrike/foundry-js": "0.17.1",
20-
"dompurify": "3.2.6"
17+
"dompurify": "3.2.6",
18+
"esbuild": "0.25.9"
2119
},
2220
"devDependencies": {
23-
"@testing-library/dom": "10.4.0",
24-
"jsdom": "25.0.1",
25-
"vite": "7.1.5",
26-
"vitest": "3.2.4"
27-
},
28-
"optionalDependencies": {
29-
"@rollup/rollup-darwin-arm64": "4.50.2"
21+
"@babel/core": "7.22.5",
22+
"@babel/preset-env": "7.22.5",
23+
"@testing-library/dom": "10.4.1",
24+
"babel-jest": "30.1.2",
25+
"jest": "30.1.2",
26+
"jest-environment-jsdom": "30.1.2",
27+
"jest-mock": "30.0.5"
3028
},
3129
"packageManager": "[email protected]+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
3230
}

0 commit comments

Comments
 (0)