mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Merge pull request #2942 from microsoft/alex/smoke-test-esbuild
Add smoke test for packaging using esbuild
This commit is contained in:
commit
726cbbecbc
11 changed files with 105 additions and 5 deletions
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
|
|
@ -50,6 +50,9 @@ jobs:
|
|||
- name: Package using webpack plugin
|
||||
run: npm run package-for-smoketest --prefix webpack-plugin
|
||||
|
||||
- name: Package using esbuild
|
||||
run: npm run package-for-smoketest-esbuild
|
||||
|
||||
- name: Run smoke test
|
||||
run: npm run smoketest
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export function removeDir(_dirPath: string, keep?: (filename: string) => boolean
|
|||
for (const entry of entries) {
|
||||
const filePath = path.join(dirPath, entry);
|
||||
const relativeFilePath = path.join(relativeDirPath, entry);
|
||||
if (keep(relativeFilePath)) {
|
||||
if (keep!(relativeFilePath)) {
|
||||
keepsFiles = true;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,11 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n`
|
|||
'/* MONACOCHANGE */false/* END MONACOCHANGE */'
|
||||
);
|
||||
|
||||
tsServices = tsServices.replace(
|
||||
/module.exports = ts;/m,
|
||||
'/* MONACOCHANGE */ /*module.exports = ts;*/ /* END MONACOCHANGE */'
|
||||
);
|
||||
|
||||
// Flag any new require calls (outside comments) so they can be corrected preemptively.
|
||||
// To avoid missing cases (or using an even more complex regex), temporarily remove comments
|
||||
// about require() and then check for lines actually calling require().
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
"scripts": {
|
||||
"build-website": "ts-node ./build/website && npm run typedoc",
|
||||
"import-typescript": "ts-node ./build/importTypescript",
|
||||
"package-for-smoketest-esbuild": "ts-node ./test/smoke/package-esbuild",
|
||||
"playwright-install": "node ./node_modules/playwright/install.js",
|
||||
"playwright-install-deps": "playwright install-deps",
|
||||
"postinstall": "ts-node ./build/postinstall",
|
||||
|
|
|
|||
|
|
@ -162604,7 +162604,7 @@ if (typeof process === "undefined" || process.browser) {
|
|||
globalThis.toolsVersion = ts.versionMajorMinor;
|
||||
}
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
module.exports = ts;
|
||||
/* MONACOCHANGE */ /*module.exports = ts;*/ /* END MONACOCHANGE */
|
||||
}
|
||||
var ts;
|
||||
(function (ts) {
|
||||
|
|
|
|||
|
|
@ -162604,7 +162604,7 @@ if (typeof process === "undefined" || process.browser) {
|
|||
globalThis.toolsVersion = ts.versionMajorMinor;
|
||||
}
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
module.exports = ts;
|
||||
/* MONACOCHANGE */ /*module.exports = ts;*/ /* END MONACOCHANGE */
|
||||
}
|
||||
var ts;
|
||||
(function (ts) {
|
||||
|
|
|
|||
10
test/smoke/esbuild/esbuild.html
Normal file
10
test/smoke/esbuild/esbuild.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="editor-container" style="position: absolute; width: 500px; height: 400px"></div>
|
||||
<script type="text/javascript" src="out/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
21
test/smoke/esbuild/index.js
Normal file
21
test/smoke/esbuild/index.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import * as monaco from '../../../release/esm/vs/editor/editor.main.js';
|
||||
|
||||
self.MonacoEnvironment = {
|
||||
getWorkerUrl: function (moduleId, label) {
|
||||
if (label === 'json') {
|
||||
return './out/vs/language/json/json.worker.js';
|
||||
}
|
||||
if (label === 'css' || label === 'scss' || label === 'less') {
|
||||
return './out/vs/language/css/css.worker.js';
|
||||
}
|
||||
if (label === 'html' || label === 'handlebars' || label === 'razor') {
|
||||
return './out/vs/language/html/html.worker.js';
|
||||
}
|
||||
if (label === 'typescript' || label === 'javascript') {
|
||||
return './out/vs/language/typescript/ts.worker.js';
|
||||
}
|
||||
return './out/vs/editor/editor.worker.js';
|
||||
}
|
||||
};
|
||||
|
||||
window.monacoAPI = monaco;
|
||||
58
test/smoke/package-esbuild.ts
Normal file
58
test/smoke/package-esbuild.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as esbuild from 'esbuild';
|
||||
import * as path from 'path';
|
||||
import { removeDir } from '../../build/fs';
|
||||
|
||||
removeDir('test/smoke/esbuild/out', (entry) => /esbuild.html$/.test(entry));
|
||||
|
||||
const workerEntryPoints = [
|
||||
'vs/language/json/json.worker.js',
|
||||
'vs/language/css/css.worker.js',
|
||||
'vs/language/html/html.worker.js',
|
||||
'vs/language/typescript/ts.worker.js',
|
||||
'vs/editor/editor.worker.js'
|
||||
];
|
||||
|
||||
build({
|
||||
entryPoints: workerEntryPoints.map((entry) => path.join(__dirname, `../../release/esm/${entry}`)),
|
||||
bundle: true,
|
||||
format: 'iife',
|
||||
logLevel: 'silent',
|
||||
outbase: path.join(__dirname, '../../release/esm/'),
|
||||
outdir: path.join(__dirname, 'esbuild/out')
|
||||
});
|
||||
|
||||
build({
|
||||
entryPoints: [path.join(__dirname, 'esbuild/index.js')],
|
||||
bundle: true,
|
||||
format: 'iife',
|
||||
logLevel: 'silent',
|
||||
outdir: path.join(__dirname, 'esbuild/out'),
|
||||
loader: {
|
||||
'.ttf': 'file'
|
||||
}
|
||||
});
|
||||
|
||||
function build(opts: esbuild.BuildOptions) {
|
||||
esbuild.build(opts).then((result) => {
|
||||
const errors = result.errors;
|
||||
const warnings = result.warnings.filter((w) => {
|
||||
return (
|
||||
w.text !==
|
||||
'Top-level "this" will be replaced with undefined since this file is an ECMAScript module'
|
||||
);
|
||||
});
|
||||
if (errors.length > 0) {
|
||||
console.log(`errors:`);
|
||||
console.error(errors);
|
||||
}
|
||||
if (warnings.length > 0) {
|
||||
console.log(`warnings:`);
|
||||
console.error(warnings);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ async function runTests() {
|
|||
// uncomment to shortcircuit and run a specific combo
|
||||
// await runTest('webpack', 'chromium'); return;
|
||||
|
||||
for (const type of ['amd', 'webpack']) {
|
||||
for (const type of ['amd', 'webpack', 'esbuild']) {
|
||||
await runTest(type, 'chromium');
|
||||
await runTest(type, 'firefox');
|
||||
// await runTest(type, 'webkit');
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ const TESTS_TYPE = process.env.TESTS_TYPE || 'amd';
|
|||
const URL =
|
||||
TESTS_TYPE === 'amd'
|
||||
? `http://127.0.0.1:${PORT}/test/smoke/amd.html`
|
||||
: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`;
|
||||
: TESTS_TYPE === 'webpack'
|
||||
? `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`
|
||||
: `http://127.0.0.1:${PORT}/test/smoke/esbuild/esbuild.html`;
|
||||
|
||||
suite(`Smoke Test '${TESTS_TYPE}' on '${browserType}'`, () => {
|
||||
/** @type {playwright.Browser} */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue