File tree Expand file tree Collapse file tree 5 files changed +16
-0
lines changed Expand file tree Collapse file tree 5 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ export const HEADMATTER_FIELDS = [
6666 'monacoTypesSource' ,
6767 'monacoTypesAdditionalPackages' ,
6868 'monacoRunAdditionalDeps' ,
69+ 'monacoRunUseStrict' ,
6970 'remoteAssets' ,
7071 'selectable' ,
7172 'record' ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import deps from '#slidev/monaco-run-deps'
55import setups from '#slidev/setups/code-runners'
66import { createSingletonPromise } from '@antfu/utils'
77import { ref } from 'vue'
8+ import { configs } from '../env'
89
910export default createSingletonPromise ( async ( ) => {
1011 const runners : Record < string , CodeRunner > = {
@@ -63,6 +64,7 @@ function runJavaScript(code: string): CodeRunnerOutputs {
6364 vmConsole . clear = ( ) => result . value . length = 0
6465 try {
6566 const safeJS = `return async (console, __slidev_import, __slidev_on_error) => {
67+ ${ configs . monacoRunUseStrict ? `"use strict";` : '' }
6668 try {
6769 ${ sanitizeJS ( code ) }
6870 } catch (e) {
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export function getDefaultConfig(): SlidevConfig {
1414 monacoTypesAdditionalPackages : [ ] ,
1515 monacoTypesIgnorePackages : [ ] ,
1616 monacoRunAdditionalDeps : [ ] ,
17+ monacoRunUseStrict : true ,
1718 download : false ,
1819 export : { } as ResolvedExportOptions ,
1920 info : false ,
Original file line number Diff line number Diff line change @@ -264,6 +264,12 @@ export interface HeadmatterConfig extends TransitionOptions {
264264 * @default []
265265 */
266266 monacoRunAdditionalDeps ?: string [ ]
267+ /**
268+ * Whether to run monaco runnable code in strict mode
269+ *
270+ * @default true
271+ */
272+ monacoRunUseStrict ?: boolean
267273 /**
268274 * Seo meta tags settings
269275 *
Original file line number Diff line number Diff line change 505505 "markdownDescription" : " Additional local modules to load as dependencies of monaco runnable" ,
506506 "default" : []
507507 },
508+ "monacoRunUseStrict" : {
509+ "type" : " boolean" ,
510+ "description" : " Whether to run monaco runnable code in strict mode" ,
511+ "markdownDescription" : " Whether to run monaco runnable code in strict mode" ,
512+ "default" : true
513+ },
508514 "seoMeta" : {
509515 "$ref" : " #/definitions/SeoMeta" ,
510516 "description" : " Seo meta tags settings" ,
You can’t perform that action at this time.
0 commit comments