Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e65836

Browse filesBrowse files
Factored out codemirror as chunked lazy based import (#2252)
* Factored out codemirror as chunked lazy based import
1 parent 796373c commit 7e65836
Copy full SHA for 7e65836

File tree

Expand file treeCollapse file tree

7 files changed

+58
-9
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+58
-9
lines changed

‎core/src/core.js

Copy file name to clipboardExpand all lines: core/src/core.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import {
3434
inputFailure,
3535
} from "./hooks.js";
3636

37+
import codemirror from "./plugins/codemirror.js";
38+
export { codemirror };
39+
3740
import { stdlib, optional } from "./stdlib.js";
3841
export { stdlib, optional, inputFailure };
3942

‎core/src/plugins.js

Copy file name to clipboardExpand all lines: core/src/plugins.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// ⚠️ This file is an artifact: DO NOT MODIFY
22
export default {
3+
codemirror: () =>
4+
import(
5+
/* webpackIgnore: true */
6+
"./plugins/codemirror.js"
7+
),
38
["deprecations-manager"]: () =>
49
import(
510
/* webpackIgnore: true */

‎core/src/plugins/codemirror.js

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// lazy loaded on-demand codemirror related files
2+
export default {
3+
get core() {
4+
return import(/* webpackIgnore: true */ "../3rd-party/codemirror.js");
5+
},
6+
get state() {
7+
return import(
8+
/* webpackIgnore: true */ "../3rd-party/codemirror_state.js"
9+
);
10+
},
11+
get python() {
12+
return import(
13+
/* webpackIgnore: true */ "../3rd-party/codemirror_lang-python.js"
14+
);
15+
},
16+
get language() {
17+
return import(
18+
/* webpackIgnore: true */ "../3rd-party/codemirror_language.js"
19+
);
20+
},
21+
get view() {
22+
return import(
23+
/* webpackIgnore: true */ "../3rd-party/codemirror_view.js"
24+
);
25+
},
26+
get commands() {
27+
return import(
28+
/* webpackIgnore: true */ "../3rd-party/codemirror_commands.js"
29+
);
30+
},
31+
};

‎core/src/plugins/py-editor.js

Copy file name to clipboardExpand all lines: core/src/plugins/py-editor.js
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Hook, XWorker, dedent, defineProperties } from "polyscript/exports";
33
import { TYPES, offline_interpreter, relative_url, stdlib } from "../core.js";
44
import { notify } from "./error.js";
5+
import codemirror from "./codemirror.js";
56

67
const RUN_BUTTON = `<svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg>`;
78

@@ -194,14 +195,12 @@ const init = async (script, type, interpreter) => {
194195
{ keymap },
195196
{ defaultKeymap, indentWithTab },
196197
] = await Promise.all([
197-
import(/* webpackIgnore: true */ "../3rd-party/codemirror.js"),
198-
import(/* webpackIgnore: true */ "../3rd-party/codemirror_state.js"),
199-
import(
200-
/* webpackIgnore: true */ "../3rd-party/codemirror_lang-python.js"
201-
),
202-
import(/* webpackIgnore: true */ "../3rd-party/codemirror_language.js"),
203-
import(/* webpackIgnore: true */ "../3rd-party/codemirror_view.js"),
204-
import(/* webpackIgnore: true */ "../3rd-party/codemirror_commands.js"),
198+
codemirror.core,
199+
codemirror.state,
200+
codemirror.python,
201+
codemirror.language,
202+
codemirror.view,
203+
codemirror.commands,
205204
]);
206205

207206
let isSetup = script.hasAttribute("setup");

‎core/types/core.d.ts

Copy file name to clipboardExpand all lines: core/types/core.d.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function donkey(options: any): Promise<{
77
kill: () => void;
88
}>;
99
export function offline_interpreter(config: any): string;
10+
import codemirror from './plugins/codemirror.js';
1011
import { stdlib } from "./stdlib.js";
1112
import { optional } from "./stdlib.js";
1213
import { inputFailure } from "./hooks.js";
@@ -63,4 +64,4 @@ declare const exportedHooks: {
6364
};
6465
declare const exportedConfig: {};
6566
declare const exportedWhenDefined: any;
66-
export { stdlib, optional, inputFailure, TYPES, relative_url, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };
67+
export { codemirror, stdlib, optional, inputFailure, TYPES, relative_url, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };

‎core/types/plugins.d.ts

Copy file name to clipboardExpand all lines: core/types/plugins.d.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare const _default: {
2+
codemirror: () => Promise<typeof import("./plugins/codemirror.js")>;
23
"deprecations-manager": () => Promise<typeof import("./plugins/deprecations-manager.js")>;
34
donkey: () => Promise<typeof import("./plugins/donkey.js")>;
45
error: () => Promise<typeof import("./plugins/error.js")>;

‎core/types/plugins/codemirror.d.ts

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare namespace _default {
2+
const core: Promise<typeof import("../3rd-party/codemirror.js")>;
3+
const state: Promise<typeof import("../3rd-party/codemirror_state.js")>;
4+
const python: Promise<typeof import("../3rd-party/codemirror_lang-python.js")>;
5+
const language: Promise<typeof import("../3rd-party/codemirror_language.js")>;
6+
const view: Promise<typeof import("../3rd-party/codemirror_view.js")>;
7+
const commands: Promise<typeof import("../3rd-party/codemirror_commands.js")>;
8+
}
9+
export default _default;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.