Skip to content

Commit 65f246f

Browse files
authored
Website fixes (#1481)
1 parent 0f6c98d commit 65f246f

File tree

12 files changed

+57
-45
lines changed

12 files changed

+57
-45
lines changed

scripts/check-dependencies/check-dependencies.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const ignore = {
66
'tests/observables': [
77
'moon-unit',
88
],
9+
'web-site': [
10+
'jsdom', // pinned because of a bug https://github.com/jsdom/jsdom/issues/3959
11+
],
912
};
1013

1114
const pkgs = await glob([

tests/eslint/eslint.config.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@ export default [
24332433
'packages/core-js-compat/src/**',
24342434
'scripts/**',
24352435
'tests/**/*.mjs',
2436-
'website/*.mjs',
2436+
'website/**.mjs',
24372437
],
24382438
languageOptions: {
24392439
// zx
@@ -2521,9 +2521,17 @@ export default [
25212521
},
25222522
rules: {
25232523
...transpiledAndPolyfilled,
2524-
'no-restricted-globals': 'off',
2525-
'unicorn/prefer-global-this': 'off',
2524+
'no-restricted-globals': OFF,
2525+
'unicorn/prefer-global-this': OFF,
25262526
'@stylistic/quotes': [ERROR, 'single', { allowTemplateLiterals: ALWAYS }],
25272527
},
25282528
},
2529+
{
2530+
files: [
2531+
'website/**',
2532+
],
2533+
rules: {
2534+
'import/no-unresolved': OFF,
2535+
},
2536+
},
25292537
];

website/build-local.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
import { join } from 'node:path';
55

66
const BUILD_SRC_DIR = './';
7-
const BUNDLES_DIR = 'bundles';
87

98
async function hasDocsLocal(srcDir) {
109
const target = join(srcDir, 'docs/web/docs');
@@ -20,7 +19,7 @@ try {
2019

2120
const version = { branch: targetBranch, label: targetBranch };
2221
await hasDocsLocal(BUILD_SRC_DIR);
23-
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR);
22+
await buildAndCopyCoreJS(version, BUILD_SRC_DIR);
2423

2524
await copyBabelStandalone(BUILD_SRC_DIR);
2625
await copyBlogPosts(BUILD_SRC_DIR);

website/build.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-unresolved -- dependencies are not installed */
21
import { getDefaultVersion } from './scripts/helpers.mjs';
32
import fm from 'front-matter';
43
import { JSDOM } from 'jsdom';

website/package-lock.json

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

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@vitejs/plugin-legacy": "^7.2.1",
1212
"front-matter": "^4.0.2",
1313
"highlight.js": "^11.11.1",
14-
"jsdom": "^27.0.1",
14+
"jsdom": "27.0.0",
1515
"marked": "^16.4.1",
1616
"marked-alert": "^2.1.2",
1717
"marked-gfm-heading-id": "^4.1.2",

website/scripts/helpers.mjs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,31 @@ export async function copyCommonFiles(srcDir) {
7474
console.timeEnd('Copied common files');
7575
}
7676

77-
export async function buildAndCopyCoreJS(version, srcDir, destDir, checkout = false, cache = false) {
77+
export async function buildAndCopyCoreJS(version, srcDir, cacheDir = null, checkout = false) {
78+
async function bundlePackage(esModules) {
79+
await exec(`npm run bundle-package${ esModules ? ' esmodules' : '' }`, { cwd: srcDir });
80+
const bundleName = `core-js-bundle${ esModules ? '-esmodules' : '' }.js`;
81+
const srcPath = join(srcDir, 'packages/core-js-bundle/minified.js');
82+
const destPath = join(srcDir, 'website/src/public/bundles/', target, bundleName);
83+
await cp(srcPath, destPath);
84+
if (cacheDir !== null) {
85+
const cachePath = join(cacheDir, target, bundleName);
86+
await cp(srcPath, cachePath);
87+
}
88+
}
89+
7890
const target = version.branch ?? version.tag;
79-
const name = version.path ?? version.label;
8091
console.log(`Building and copying core-js for ${ target }`);
81-
const targetBundlePath = `${ destDir }/${ target }/`;
92+
const targetBundlePath = join(cacheDir ?? '', target);
8293

83-
if (cache && await isExists(targetBundlePath)) {
94+
if (cacheDir !== null && await isExists(targetBundlePath)) {
8495
console.time('Core JS bundles copied');
8596
const bundlePath = join(targetBundlePath, 'core-js-bundle.js');
86-
const destBundlePath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle.js');
87-
const esmodulesBundlePath = join(targetBundlePath, 'core-js-bundle-esmodules.js');
88-
const esmodulesDestBundlePath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle-esmodules.js');
97+
const destBundlePath = join(srcDir, 'website/src/public/bundles/', target, 'core-js-bundle.js');
8998
await cp(bundlePath, destBundlePath);
99+
100+
const esmodulesBundlePath = join(targetBundlePath, 'core-js-bundle-esmodules.js');
101+
const esmodulesDestBundlePath = join(srcDir, 'website/src/public/bundles/', target, 'core-js-bundle-esmodules.js');
90102
await cp(esmodulesBundlePath, esmodulesDestBundlePath);
91103
console.timeEnd('Core JS bundles copied');
92104
return;
@@ -97,19 +109,10 @@ export async function buildAndCopyCoreJS(version, srcDir, destDir, checkout = fa
97109
await checkoutVersion(version, srcDir);
98110
}
99111
await installDependencies(srcDir);
100-
await exec('npm run bundle-package', { cwd: srcDir });
101-
const bundlePath = join(srcDir, 'packages/core-js-bundle/minified.js');
102-
const destPath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle.js');
103-
const destBundlePath = join(targetBundlePath, 'core-js-bundle.js');
104-
await cp(bundlePath, destPath);
105-
await cp(bundlePath, destBundlePath);
106-
107-
await exec('npm run bundle-package esmodules', { cwd: srcDir });
108-
const esmodulesBundlePath = join(srcDir, 'packages/core-js-bundle/minified.js');
109-
const esmodulesDestBundlePath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle-esmodules.js');
110-
const destEsmodulesBundlePath = join(targetBundlePath, 'core-js-bundle-esmodules.js');
111-
await cp(esmodulesBundlePath, esmodulesDestBundlePath);
112-
await cp(esmodulesBundlePath, destEsmodulesBundlePath);
112+
113+
await bundlePackage(false);
114+
await bundlePackage(true);
115+
113116
console.timeEnd('Core JS bundles built');
114117
}
115118

website/scripts/runner.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ try {
195195
const versions = await getVersions(targetBranch);
196196
for (const version of versions) {
197197
await copyDocsToBuilder(version);
198-
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true, true);
198+
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true);
199199
}
200200
} else {
201201
const version = { branch: targetBranch, label: targetBranch };
202202
await hasDocs(version, BUILD_SRC_DIR);
203-
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true, true);
203+
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true);
204204
}
205205

206206
await prepareBuilder(targetBranch);

website/src/js/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-unresolved -- dependencies are not installed */
21
import '../scss/app.scss';
32
import hljs from 'highlight.js/lib/core';
43
import javascript from 'highlight.js/lib/languages/javascript';

website/src/js/playground.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-unresolved -- dependencies are not installed */
21
/* global Babel -- global scope directive */
32
import hljs from 'highlight.js/lib/core';
43
import javascript from 'highlight.js/lib/languages/javascript';

0 commit comments

Comments
 (0)