@live-codes/browser-compilers 0.5.1 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -3
- package/dist/@testing-library/dom.js +62 -0
- package/dist/@testing-library/jest-dom.js +43 -0
- package/dist/@testing-library/react.js +99 -0
- package/dist/eslint/eslint.js +143 -0
- package/package.json +12 -10
- package/scripts/utils.js +45 -0
- package/scripts/vendors.js +31 -27
- package/vendor_modules/imports/@testing-library/dom.js +1 -0
- package/vendor_modules/imports/@testing-library/jest-dom.js +1 -0
- package/vendor_modules/imports/@testing-library/react.js +1 -0
- package/vendor_modules/imports/eslint.js +1 -0
- package/dist/monaco-editor/codicon-2HT6E3BE.ttf +0 -0
- package/dist/monaco-editor/css.worker.js +0 -65
- package/dist/monaco-editor/editor.worker.js +0 -6
- package/dist/monaco-editor/html.worker.js +0 -455
- package/dist/monaco-editor/json.worker.js +0 -38
- package/dist/monaco-editor/monaco-editor.css +0 -1
- package/dist/monaco-editor/monaco-editor.js +0 -800
- package/dist/monaco-editor/ts.worker.js +0 -35324
- package/scripts/patch.js +0 -25
- package/vendor_modules/imports/monaco-editor.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-codes/browser-compilers",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Compilers that run in the browser, for use in livecodes.io",
|
|
5
5
|
"author": "Hatem Hosny",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,12 +30,15 @@
|
|
|
30
30
|
"@esbuild-plugins/node-modules-polyfill": "0.1.4",
|
|
31
31
|
"@mdx-js/mdx": "2.0.0",
|
|
32
32
|
"@prettier/plugin-pug": "1.19.2",
|
|
33
|
+
"@testing-library/dom": "8.12.0",
|
|
34
|
+
"@testing-library/jest-dom": "5.16.3",
|
|
35
|
+
"@testing-library/react": "12.1.4",
|
|
33
36
|
"@webassemblyjs/wast-refmt": "1.11.1",
|
|
34
37
|
"babel-preset-solid": "1.3.5",
|
|
35
38
|
"esbuild-plugin-cache": "0.2.9",
|
|
36
39
|
"esbuild-plugin-velcro": "0.1.1",
|
|
40
|
+
"eslint": "8.11.0",
|
|
37
41
|
"less": "4.1.2",
|
|
38
|
-
"monaco-editor": "0.31.1",
|
|
39
42
|
"postcss": "8.4.6",
|
|
40
43
|
"postcss-preset-env": "7.3.1",
|
|
41
44
|
"react": "17.0.2",
|
|
@@ -50,18 +53,17 @@
|
|
|
50
53
|
"@types/live-server": "1.2.0",
|
|
51
54
|
"@types/node": "14.0.4",
|
|
52
55
|
"@types/prettier": "2.1.6",
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "
|
|
54
|
-
"@typescript-eslint/parser": "
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "5.16.0",
|
|
57
|
+
"@typescript-eslint/parser": "5.16.0",
|
|
55
58
|
"autoprefixer": "10.4.2",
|
|
56
59
|
"cz-conventional-changelog": "3.2.0",
|
|
57
60
|
"esbuild": "0.11.12",
|
|
58
61
|
"esbuild-plugin-node-polyfills": "1.0.2",
|
|
59
|
-
"eslint": "
|
|
60
|
-
"eslint-
|
|
61
|
-
"eslint-plugin-
|
|
62
|
-
"eslint-plugin-
|
|
63
|
-
"eslint-plugin-
|
|
64
|
-
"eslint-plugin-prefer-arrow": "1.2.1",
|
|
62
|
+
"eslint-config-prettier": "8.5.0",
|
|
63
|
+
"eslint-plugin-import": "2.25.4",
|
|
64
|
+
"eslint-plugin-jest": "26.1.3",
|
|
65
|
+
"eslint-plugin-jsdoc": "38.0.6",
|
|
66
|
+
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
65
67
|
"gh-pages": "2.2.0",
|
|
66
68
|
"live-server": "1.2.1",
|
|
67
69
|
"mkdirp": "1.0.4",
|
package/scripts/utils.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
var path = require('path');
|
|
3
|
+
|
|
4
|
+
const patch = (
|
|
5
|
+
/** @type {string} */ filePath,
|
|
6
|
+
/** @type {Record<string, string>} */ replacements = {},
|
|
7
|
+
) =>
|
|
8
|
+
new Promise((resolve, reject) => {
|
|
9
|
+
fs.readFile(path.resolve(filePath), 'utf8', function (err, data) {
|
|
10
|
+
if (err) return reject(err);
|
|
11
|
+
|
|
12
|
+
var result = data;
|
|
13
|
+
for (const key of Object.keys(replacements)) {
|
|
14
|
+
result = result.split(key).join(replacements[key]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fs.writeFile(path.resolve(filePath), result, 'utf8', function (err) {
|
|
18
|
+
if (err) return reject(err);
|
|
19
|
+
|
|
20
|
+
resolve();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// https://github.com/evanw/esbuild/issues/566#issuecomment-735551834
|
|
26
|
+
const externalCjsToEsmPlugin = (external) => ({
|
|
27
|
+
name: 'external',
|
|
28
|
+
setup(build) {
|
|
29
|
+
let escape = (text) => `^${text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')}$`;
|
|
30
|
+
let filter = new RegExp(external.map(escape).join('|'));
|
|
31
|
+
build.onResolve({ filter: /.*/, namespace: 'external' }, (args) => ({
|
|
32
|
+
path: args.path,
|
|
33
|
+
external: true,
|
|
34
|
+
}));
|
|
35
|
+
build.onResolve({ filter }, (args) => ({
|
|
36
|
+
path: args.path,
|
|
37
|
+
namespace: 'external',
|
|
38
|
+
}));
|
|
39
|
+
build.onLoad({ filter: /.*/, namespace: 'external' }, (args) => ({
|
|
40
|
+
contents: `export * from ${JSON.stringify(args.path)}`,
|
|
41
|
+
}));
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
module.exports = { patch, externalCjsToEsmPlugin };
|
package/scripts/vendors.js
CHANGED
|
@@ -5,7 +5,7 @@ const esbuild = require('esbuild');
|
|
|
5
5
|
const NodeModulesPolyfills = require('@esbuild-plugins/node-modules-polyfill').default;
|
|
6
6
|
const GlobalsPolyfills = require('@esbuild-plugins/node-globals-polyfill').default;
|
|
7
7
|
|
|
8
|
-
const { patch } = require('./
|
|
8
|
+
const { patch, externalCjsToEsmPlugin } = require('./utils');
|
|
9
9
|
|
|
10
10
|
const nodePolyfills = [
|
|
11
11
|
NodeModulesPolyfills(),
|
|
@@ -33,32 +33,6 @@ const baseOptions = {
|
|
|
33
33
|
define: { global: 'window', 'process.env.NODE_ENV': '"production"' },
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
// Monaco editor
|
|
37
|
-
esbuild.buildSync({
|
|
38
|
-
...baseOptions,
|
|
39
|
-
entryPoints: ['vendor_modules/imports/monaco-editor.ts'],
|
|
40
|
-
outfile: 'dist/monaco-editor/monaco-editor.js',
|
|
41
|
-
loader: { '.ttf': 'file' },
|
|
42
|
-
format: 'esm',
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Monaco editor workers
|
|
46
|
-
const entryFiles = [
|
|
47
|
-
'node_modules/monaco-editor/esm/vs/language/json/json.worker.js',
|
|
48
|
-
'node_modules/monaco-editor/esm/vs/language/css/css.worker.js',
|
|
49
|
-
'node_modules/monaco-editor/esm/vs/language/html/html.worker.js',
|
|
50
|
-
'node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js',
|
|
51
|
-
'node_modules/monaco-editor/esm/vs/editor/editor.worker.js',
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
entryFiles.forEach((entry) => {
|
|
55
|
-
esbuild.build({
|
|
56
|
-
...baseOptions,
|
|
57
|
-
entryPoints: [entry],
|
|
58
|
-
outdir: './dist/monaco-editor',
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
36
|
// sass
|
|
63
37
|
patch('node_modules/sass/sass.dart.js', {
|
|
64
38
|
'var self = Object.create(dartNodePreambleSelf);': 'var self = window;',
|
|
@@ -72,6 +46,15 @@ patch('node_modules/sass/sass.dart.js', {
|
|
|
72
46
|
});
|
|
73
47
|
});
|
|
74
48
|
|
|
49
|
+
// Eslint
|
|
50
|
+
esbuild.build({
|
|
51
|
+
...baseOptions,
|
|
52
|
+
entryPoints: ['vendor_modules/imports/eslint.js'],
|
|
53
|
+
outfile: 'dist/eslint/eslint.js',
|
|
54
|
+
globalName: 'eslint',
|
|
55
|
+
plugins: nodePolyfills,
|
|
56
|
+
});
|
|
57
|
+
|
|
75
58
|
// Less
|
|
76
59
|
esbuild.buildSync({
|
|
77
60
|
...baseOptions,
|
|
@@ -275,3 +258,24 @@ fs.copyFileSync(
|
|
|
275
258
|
path.resolve(vendor_modules_src + '/svgbob-wasm/svgbob-wasm.js'),
|
|
276
259
|
path.resolve(targetDir + '/svgbob-wasm/svgbob-wasm.js'),
|
|
277
260
|
);
|
|
261
|
+
|
|
262
|
+
// @testing-library
|
|
263
|
+
['dom.js', 'jest-dom.js', 'react.js'].forEach(
|
|
264
|
+
// entryPoints did not work properly!
|
|
265
|
+
(mod) => {
|
|
266
|
+
esbuild
|
|
267
|
+
.build({
|
|
268
|
+
...baseOptions,
|
|
269
|
+
entryPoints: ['vendor_modules/imports/@testing-library/' + mod],
|
|
270
|
+
outdir: 'dist/@testing-library/',
|
|
271
|
+
format: 'esm',
|
|
272
|
+
plugins: [externalCjsToEsmPlugin(['react'])],
|
|
273
|
+
})
|
|
274
|
+
.then(() => {
|
|
275
|
+
if (mod !== 'jest-dom.js') return;
|
|
276
|
+
patch('dist/@testing-library/jest-dom.js', {
|
|
277
|
+
'expect.extend': 'window.jestLite?.core.expect.extend',
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
},
|
|
281
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@testing-library/dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@testing-library/react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Linter } from '../../node_modules/eslint/lib/linter/linter.js';
|
|
Binary file
|