Skip to content

Commit

Permalink
Make REPL use Babel 8 to simplify import map (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfooman authored Aug 30, 2024
1 parent 6054c70 commit 7849625
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 22 deletions.
21 changes: 6 additions & 15 deletions repl/importmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,12 @@ const reactMin = {
const imports = {
"@runtime-type-inspector/runtime" : '../src-runtime/index.js',
"@runtime-type-inspector/transpiler": '../src-transpiler/index.js',
"@babel/parser" : importFile(`
// Note: this is still ugly, but Babel 8 should be "nice" ESM (when it's out)
// Test: const {parse} = await import("@babel/parser");
// Now we have this, but requires never npm version:
// https://github.com/kungfooman/babel-8-via-importmap/blob/main/importmap.js
globalThis.exports = {};
const ret = await import("${nodeModules}@babel/parser/lib/index.js");
export const {parse, parseExpression, tokTypes} = globalThis.exports;
export default exports;
`),
"display-anything" : "./node_modules/display-anything/src/index.js",
"worker-with-import-map" : "./node_modules/worker-with-import-map/src/index.js",
"test-import-validation-b" : "../test/typechecking/import-validation/b.js",
//"@babel/helper-plugin-utils" : "./babel-helper-plugin-utils.js",
//"@babel/plugin-syntax-typescript" : "./babel-plugin-syntax-typescript.js",
"@babel/parser" : nodeModules + '@babel/parser/lib/index.js',
"display-anything" : nodeModules + 'display-anything/src/index.js',
"worker-with-import-map" : nodeModules + 'worker-with-import-map/src/index.js',
"test-import-validation-b" : '../test/typechecking/import-validation/b.js',
//"@babel/helper-plugin-utils" : './babel-helper-plugin-utils.js',
//"@babel/plugin-syntax-typescript" : './babel-plugin-syntax-typescript.js',
"fs" : importFile("export default {};"),
"typescript" : importFile(`
globalThis.module = {exports: {}};
Expand Down
101 changes: 94 additions & 7 deletions repl/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"access": "public"
},
"dependencies": {
"@babel/parser": "^8.0.0-alpha.12",
"@runtime-type-inspector/transpiler": "^4.0.0",
"ace-builds": "^1.35.2",
"display-anything": "^1.1.0",
Expand Down

0 comments on commit 7849625

Please sign in to comment.