-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
Description
Describe the bug
As described in #2186, monacoRunAdditionalDeps is ignored so the import of packages fails in monaco-run.
Minimal reproduction
- Create a slide with
monaco-runwhere some packages are impoted:```ts {monaco-run} import { signal, effect } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); TestBed.runInInjectionContext(() => { const valueSignal = signal(1); console.log('Start'); effect(() => { console.log('Signal:', valueSignal()); }); TestBed.flushEffects(); console.log('After effect'); valueSignal.set(1); TestBed.flushEffects(); console.log('End'); }); - Add
monacoRunAdditionalDepsto frontmatter:
monacoRunAdditionalDeps:
- '@angular/platform-browser-dynamic'
- '@angular/core'
- 'rxjs'
- '@/snippets/angular-testbed'
- Install the dependencies in the project
- Start the dev server and see the error "Module not found"
Environment
- Slidev version: 52.10.1
Possible fix
-
monacoRunAdditionalDepsis completely ignored in the code. I think something like this is needed to add the dependencies inmonacoRunAdditionalDeps.const deps = uniq(data.features.monaco.deps.concat(data.config.monacoTypesAdditionalPackages).concat(data.config.monacoRunAdditionalDeps))
I tested it and it works.
-
But that solution only allows using
monacoRunAdditionalDepsin headmatter. The documentation talks about from matter. Maybe something like this could work:const perSlideDeps = data.slides.flatMap(slide => slide.frontmatter?.monacoRunAdditionalDeps || []) const deps = uniq(data.features.monaco.deps.concat(data.config.monacoTypesAdditionalPackages).concat(data.config.monacoRunAdditionalDeps).concat(perSlideDeps))