Skip to content

Multi-file support#934

Open
hatemhosny wants to merge 108 commits intodevelopfrom
multi-file-support
Open

Multi-file support#934
hatemhosny wants to merge 108 commits intodevelopfrom
multi-file-support

Conversation

@hatemhosny
Copy link
Collaborator

@hatemhosny hatemhosny commented Jan 31, 2026

This PR introduces multi-file projects in LiveCodes. This closes #886

This is still work in progress. Performance improvements, tests, fixes and docs still need to be added.
However, I believe it is ready enough to get feedback.

Demos:
JS: https://multi-file-support.livecodes.pages.dev/?template=multifile-javascript
TS: https://multi-file-support.livecodes.pages.dev/?template=multifile-typescript
React: https://multi-file-support.livecodes.pages.dev/?template=multifile-react
Vue: https://multi-file-support.livecodes.pages.dev/?template=multifile-vue
Preact: https://multi-file-support.livecodes.pages.dev/?template=multifile-preact
Svelte: https://multi-file-support.livecodes.pages.dev/?template=multifile-svelte
Solid: https://multi-file-support.livecodes.pages.dev/?template=multifile-solid
Lit: https://multi-file-support.livecodes.pages.dev/?template=multifile-lit
Jest: https://multi-file-support.livecodes.pages.dev/?template=multifile-jest
import from GitHub: https://multi-file-support.livecodes.pages.dev/?x=https://github.com/vitejs/vite/tree/main/packages/create-vite/template-svelte-ts

Note: Although this is a huge change that required large changes in how LiveCodes works, however, it should largely be backward-compatible. LiveCodes still has first-class support for the 3-editor (single file) projects. Old projects should continue to work normally. The only major change is that importing code (e.g. from GitHub) now uses multi-file projects.

image

As detailed in the issue, these are the implementation details:

  • There is no plan to implement a full virtual file system or introduce a new build system (e.g. rollup/rolldown)
  • The multi-file support uses importmaps + data URLs, which are already being heavily used in LiveCodes.
  • When the config object has a files property, the markup, style and script properties are ignored.
  • Additional files can be added. The file extension determines file type and used compiler.
  • File names can have slashes to simulate directory structure (e.g. components/MyComponent.ripple)
  • Additional files have to be imported (or added as scripts or stylesheets) from the main entry file (specified using mainFile property and defaults to index.html)
  • Script files (e.g. js, ts, jsx, tsx, vue, svelte, ripple, etc) are compiled to js and made available using importmaps.
  • Style files (e.g. css, scss, style, etc) are compiled to css and inlined in the css code that imports them.
  • Additional markup files (apart from the mainFile) are not allowed (maybe we can later implement imports for the supported template engines (e.g. pug, mustache, etc)
  • There is no plan for multi-page apps (multiple HTML files that can be linked)
  • Importing JSON makes it available as a JS object.
  • Static files can be imported (e.g. import logo from './assets/logo.png') then used as URL.
  • Binary files (e.g. images, video, audio, fonts) can be added. Files are converted to base64 data URLs. The UI supports adding them when a file extension of a binary file is used. Also they can be added by drag and drop.
  • Static files in public folder can be used from the root of the project (like in Vite).
  • Non-JS imports are not allowed (e.g. PHP, C++, Python, etc.). Maybe we can later figure out how to do that for each language (not in the scope of this PR)
  • The UI allows adding files by a button on the side of the editor tabs. Double-click on the file name allows editing it. A delete button on the tab allows deleting the file. If the tabs are wider than the available space they scroll horizontally. Tabs can be re-ordered using drag and drop.
  • Local files from the device's file system can be dragged and dropped in the editor to add the files and folders while preserving structure.
  • A new files property is added to the configuration object to persist state and to allow it to be set from the SDK. It has this type Array<{ filename: string; content: string; language?: Language; hidden?: boolean; }>.
  • A new lockFiles property disables adding files from the UI. It is set to false by default.
  • A new fileLanguages property allows mapping file extensions to languages to override the default compiler (e.g. to use solid compiler instead of react for jsx use: { jsx: "solid" })
  • There is no plan to support config files like package.json, tsconfig.json, .editorconfig, etc. Many of these settings can already be achieved by LiveCodes configuration object. However, json files can be added to a project in case the code needs to read from them.
  • importing tailwindcss (@import "tailwindcss";) in a style file (css, scss, etc) automatically enables TailwindCSS. CSS modules can be enabled by naming style files with .module. (e.g. styles.module.css)
  • There is no plan to implement a file tree viewer.
  • Now importing (e.g. from GitHub) uses multi-file projects by default.
  • Multi-file projects can be exported. The folder structure is maintained. Binary files are also exported.
  • New multi-file templates allow quick start for different projects (e.g. blank, JS, TS, React, Vue, Svelte, Solid, Jest, etc)
  • Significant improvements have been added in monaco editor including auto-complete across multiple files, go to definition, better Vue language support, etc.

This aims to have full compatibility with vite (without having to add any config files). In fact, if you drag and drop files from any vite project, they should (hopefully) work!

In addition, this feature allows interesting use-cases like having projects that use multiple frameworks simultaneously.

Please give it a try and report any issues. I would appreciate feedback.

cc: @logaretm @zyf722 @gigamaster @sharno @BassemHalim @Seth0x41 @fahdfady

@netlify
Copy link

netlify bot commented Jan 31, 2026

Deploy Preview for livecodes ready!

Name Link
🔨 Latest commit 0868399
🔍 Latest deploy log https://app.netlify.com/projects/livecodes/deploys/698181b5cbd7160007f1b833
😎 Deploy Preview https://deploy-preview-934--livecodes.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2026

Size Change: +37 kB (+3.61%)

Total Size: 1.06 MB

Filename Size Change
./build/livecodes/app.css 23.1 kB +590 B (+2.62%)
./build/livecodes/app.js 119 kB +7.5 kB (+6.71%) 🔍
./build/livecodes/codejar.js 26.1 kB +8.55 kB (+48.62%) 🚨
./build/livecodes/codemirror.js 15.3 kB +8.91 kB (+139.82%) 🆘
./build/livecodes/compile.worker.js 15.1 kB +619 B (+4.27%)
./build/livecodes/embed.js 96.6 kB +6.56 kB (+7.29%) 🔍
./build/livecodes/export.js 12.8 kB +8.92 kB (+229.4%) 🆘
./build/livecodes/format.worker.js 14.2 kB +563 B (+4.14%)
./build/livecodes/headless.js 85.3 kB +6.71 kB (+8.53%) 🔍
./build/livecodes/import-src.js 16.6 kB +369 B (+2.28%)
./build/livecodes/import.js 5.26 kB -9.37 kB (-64.01%) 🏆
./build/livecodes/lang-svelte-compiler.js 4.89 kB +204 B (+4.35%)
./build/livecodes/lang-vue-compiler.js 6.3 kB +212 B (+3.48%)
./build/livecodes/monaco-lang-astro.js 0 B -947 B (removed) 🏆
./build/livecodes/monaco-lang-clio.js 0 B -639 B (removed) 🏆
./build/livecodes/monaco-lang-imba.js 0 B -7.35 kB (removed) 🏆
./build/livecodes/monaco-lang-minizinc.js 0 B -1.74 kB (removed) 🏆
./build/livecodes/monaco-lang-prolog.js 0 B -580 B (removed) 🏆
./build/livecodes/monaco-lang-wat.js 0 B -2.46 kB (removed) 🏆
./build/livecodes/monaco.js 10.4 kB +243 B (+2.39%)
./build/livecodes/processor-tailwindcss-compiler.js 5.54 kB +303 B (+5.78%) 🔍
./build/livecodes/templates.js 33.9 kB +7.38 kB (+27.79%) 🚨
ℹ️ View Unchanged
Filename Size Change
./build/404.html 1 kB 0 B
./build/app.html 250 B 0 B
./build/index.html 2.46 kB 0 B
./build/livecodes/assets.js 8.63 kB -9 B (-0.1%)
./build/livecodes/assets/noop.js 18 B 0 B
./build/livecodes/assets/templates/diagrams-starter.html 2.19 kB 0 B
./build/livecodes/backup.js 3.74 kB +14 B (+0.38%)
./build/livecodes/blockly.js 13.5 kB +77 B (+0.57%)
./build/livecodes/broadcast.js 1.19 kB 0 B
./build/livecodes/bundle-types.js 4.4 kB +43 B (+0.99%)
./build/livecodes/code-to-image.js 9.15 kB +48 B (+0.53%)
./build/livecodes/compile.page.js 2.47 kB +62 B (+2.58%)
./build/livecodes/compiler-utils.js 3.16 kB -19 B (-0.6%)
./build/livecodes/custom-editor-utils.js 198 B 0 B
./build/livecodes/deploy.js 7 kB +99 B (+1.43%)
./build/livecodes/editor-settings.js 18.1 kB +168 B (+0.94%)
./build/livecodes/embed-ui.js 5.58 kB +34 B (+0.61%)
./build/livecodes/firebase.js 22.7 kB 0 B
./build/livecodes/google-fonts.js 7.12 kB 0 B
./build/livecodes/i18n-ar-language-info.json 5.34 kB 0 B
./build/livecodes/i18n-ar-translation.json 9.34 kB 0 B
./build/livecodes/i18n-bn-language-info.json 5.76 kB 0 B
./build/livecodes/i18n-bn-translation.json 9.69 kB 0 B
./build/livecodes/i18n-de-language-info.json 5.4 kB 0 B
./build/livecodes/i18n-de-translation.json 9.45 kB 0 B
./build/livecodes/i18n-en-language-info.json 4.63 kB 0 B
./build/livecodes/i18n-en-translation.json 8.23 kB +132 B (+1.63%)
./build/livecodes/i18n-es-language-info.json 5.12 kB 0 B
./build/livecodes/i18n-es-translation.json 9.17 kB 0 B
./build/livecodes/i18n-fa-language-info.json 5.52 kB 0 B
./build/livecodes/i18n-fa-translation.json 9.49 kB 0 B
./build/livecodes/i18n-fr-language-info.json 5.31 kB 0 B
./build/livecodes/i18n-fr-translation.json 9.43 kB 0 B
./build/livecodes/i18n-hi-language-info.json 5.93 kB 0 B
./build/livecodes/i18n-hi-translation.json 9.96 kB 0 B
./build/livecodes/i18n-id-language-info.json 4.87 kB 0 B
./build/livecodes/i18n-id-translation.json 8.69 kB 0 B
./build/livecodes/i18n-it-language-info.json 5.17 kB 0 B
./build/livecodes/i18n-it-translation.json 9.26 kB 0 B
./build/livecodes/i18n-ja-language-info.json 5.72 kB 0 B
./build/livecodes/i18n-ja-translation.json 9.62 kB 0 B
./build/livecodes/i18n-nl-language-info.json 5.07 kB 0 B
./build/livecodes/i18n-nl-translation.json 8.91 kB 0 B
./build/livecodes/i18n-pt-language-info.json 5.16 kB 0 B
./build/livecodes/i18n-pt-translation.json 9.36 kB 0 B
./build/livecodes/i18n-ru-language-info.json 5.7 kB 0 B
./build/livecodes/i18n-ru-translation.json 10.3 kB 0 B
./build/livecodes/i18n-tr-language-info.json 5.3 kB 0 B
./build/livecodes/i18n-tr-translation.json 9.25 kB 0 B
./build/livecodes/i18n-ur-language-info.json 5.97 kB 0 B
./build/livecodes/i18n-ur-translation.json 9.8 kB 0 B
./build/livecodes/i18n-zh-CN-language-info.json 5.01 kB 0 B
./build/livecodes/i18n-zh-CN-translation.json 8.65 kB 0 B
./build/livecodes/i18n.js 20.4 kB -12 B (-0.06%)
./build/livecodes/index.js 5.43 kB +84 B (+1.57%)
./build/livecodes/lang-art-template-compiler.js 1.68 kB +27 B (+1.63%)
./build/livecodes/lang-assemblyscript-compiler.js 290 B 0 B
./build/livecodes/lang-assemblyscript-script.js 386 B 0 B
./build/livecodes/lang-astro-compiler.js 2.44 kB +99 B (+4.24%)
./build/livecodes/lang-clio-compiler.js 1.58 kB +33 B (+2.13%)
./build/livecodes/lang-commonlisp-script.js 123 B 0 B
./build/livecodes/lang-cpp-script.js 1.77 kB +37 B (+2.13%)
./build/livecodes/lang-cpp-wasm-script.js 2.87 kB +34 B (+1.2%)
./build/livecodes/lang-csharp-wasm-script.js 2.21 kB +33 B (+1.52%)
./build/livecodes/lang-diagrams-compiler-esm.js 5.11 kB +21 B (+0.41%)
./build/livecodes/lang-dot-compiler.js 1.69 kB +31 B (+1.87%)
./build/livecodes/lang-ejs-compiler.js 1.66 kB +29 B (+1.78%)
./build/livecodes/lang-eta-compiler.js 1.68 kB +28 B (+1.69%)
./build/livecodes/lang-fennel-compiler.js 1.64 kB +32 B (+1.99%)
./build/livecodes/lang-gleam-compiler.js 3.13 kB +34 B (+1.1%)
./build/livecodes/lang-go-wasm-script.js 3.29 kB +32 B (+0.98%)
./build/livecodes/lang-haml-compiler.js 1.69 kB +42 B (+2.55%)
./build/livecodes/lang-handlebars-compiler.js 2 kB +44 B (+2.26%)
./build/livecodes/lang-imba-compiler.js 147 B 0 B
./build/livecodes/lang-java-script.js 4.09 kB +37 B (+0.91%)
./build/livecodes/lang-jinja-compiler.js 1.67 kB +19 B (+1.15%)
./build/livecodes/lang-julia-script.js 3.32 kB +12 B (+0.36%)
./build/livecodes/lang-liquid-compiler.js 1.71 kB +31 B (+1.84%)
./build/livecodes/lang-lua-wasm-script.js 205 B 0 B
./build/livecodes/lang-malina-compiler.js 3.03 kB +74 B (+2.5%)
./build/livecodes/lang-minizinc-script.js 2.09 kB +35 B (+1.7%)
./build/livecodes/lang-mustache-compiler.js 1.68 kB +36 B (+2.19%)
./build/livecodes/lang-nunjucks-compiler.js 2 kB +44 B (+2.25%)
./build/livecodes/lang-perl-script.js 268 B 0 B
./build/livecodes/lang-php-wasm-script.js 347 B 0 B
./build/livecodes/lang-postgresql-compiler-esm.js 1.76 kB +27 B (+1.56%)
./build/livecodes/lang-prolog-script.js 204 B 0 B
./build/livecodes/lang-pug-compiler.js 371 B 0 B
./build/livecodes/lang-python-wasm-script.js 1.89 kB +30 B (+1.61%)
./build/livecodes/lang-r-script-esm.js 2.46 kB +28 B (+1.15%)
./build/livecodes/lang-rescript-compiler-esm.js 2.2 kB +45 B (+2.09%)
./build/livecodes/lang-rescript-formatter.js 1.55 kB +38 B (+2.5%)
./build/livecodes/lang-riot-compiler.js 2.9 kB +86 B (+3.06%)
./build/livecodes/lang-ruby-wasm-script.js 1.75 kB +41 B (+2.4%)
./build/livecodes/lang-scss-compiler.js 1.71 kB 0 B
./build/livecodes/lang-solid-compiler.js 263 B 0 B
./build/livecodes/lang-sql-compiler.js 1.67 kB +31 B (+1.89%)
./build/livecodes/lang-sql-script.js 1.99 kB +34 B (+1.74%)
./build/livecodes/lang-tcl-script.js 1.85 kB +31 B (+1.7%)
./build/livecodes/lang-teal-compiler.js 1.75 kB +31 B (+1.81%)
./build/livecodes/lang-twig-compiler.js 1.67 kB +30 B (+1.82%)
./build/livecodes/lang-vento-compiler.js 1.72 kB +36 B (+2.14%)
./build/livecodes/lang-vue2-compiler.js 3.56 kB +87 B (+2.5%)
./build/livecodes/lang-wat-compiler.js 348 B 0 B
./build/livecodes/lang-wat-script.js 1.61 kB +29 B (+1.83%)
./build/livecodes/language-info.js 7.91 kB -14 B (-0.18%)
./build/livecodes/open.js 6.24 kB +18 B (+0.29%)
./build/livecodes/processor-lightningcss-compiler.js 1.91 kB +33 B (+1.76%)
./build/livecodes/processor-postcss-compiler.js 2.11 kB +81 B (+4%)
./build/livecodes/processor-unocss-compiler.js 355 B 0 B
./build/livecodes/processor-windicss-compiler.js 450 B 0 B
./build/livecodes/quill.css 697 B 0 B
./build/livecodes/quill.js 5.86 kB +56 B (+0.96%)
./build/livecodes/resources.js 3.43 kB +2 B (+0.06%)
./build/livecodes/result-utils.js 1.17 kB 0 B
./build/livecodes/share.js 3.85 kB +34 B (+0.89%)
./build/livecodes/snippets.js 6.07 kB +29 B (+0.48%)
./build/livecodes/sync-ui.js 3.29 kB +28 B (+0.86%)
./build/livecodes/sync.js 3.56 kB +43 B (+1.22%)
./build/livecodes/sync.worker.js 29.7 kB +5 B (+0.02%)
./build/sdk/livecodes.js 3.96 kB +1 B (+0.03%)
./build/sdk/livecodes.umd.js 4.01 kB -13 B (-0.32%)
./build/sdk/package.json 291 B 0 B
./build/sdk/react.js 4.26 kB 0 B
./build/sdk/vue.js 4.35 kB +1 B (+0.02%)

compressed-size-action

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 1, 2026

Deploying livecodes with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0868399
Status: ✅  Deploy successful!
Preview URL: https://de1dc491.livecodes.pages.dev
Branch Preview URL: https://multi-file-support.livecodes.pages.dev

View logs

@BassemHalim
Copy link
Contributor

Hi Dr. @hatemhosny
That's a really helpful feature it looks great!

I have a couple of thoughts/questions

  1. Just wanted to know more about why only a single main File can be selected? (also how can I select a main file) I was thinking it would be nice to be able to share a single demo link with a README.md along with the html file and when we click on one of the markup files it would render it on the right. (this can be a feature for later just wanted to know if there is a technical limitation)

  2. Can the multi-file feature be enabled by default in any of the preexisting templates or will it break backward compatibility? For example, the user can start with a basic react template then later can add an extra file.

Great job on this one it looks like it took a lot of effort

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
24.4% Duplication on New Code (required ≤ 3%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-file support RFC

2 participants