-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
next.360 build fails with "Maximum call stack size exceeded" for large dynamic imports #5399
Comments
| also tried updating our project to
|
I too got the same error after upgrading to 360 .
reverting to |
Getting the same error when importing
|
Looks like the common issue is |
@tsukhu Referencing the implementation in this gist. <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.21.2/min/vs/loader.min.js"></script> Could be added to the Then the editor setup using <script>
import { onMount } from 'svelte';
let container
onMount(async () => {
require.config({ paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.21.2/min/vs' } })
window.MonacoEnvironment = {
getWorkerUrl: function (workerId, label) {
return `data:text/javascript;charset=utf-8,${encodeURIComponent(`
self.MonacoEnvironment = {
baseUrl: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.21.2/min/'
};
importScripts('https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.21.2/min/vs/base/worker/workerMain.js');`)}`
}
}
require(['vs/editor/editor.main'], function () {
monaco.editor.create(container, {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
})
})
})
</script>
<div bind:this={container} style="width:800px;height:600px;border:1px solid grey"></div>
|
Thank you @KeithAndreRose - This worked perfectly. My vercel build time has also reduced by 20 seconds :-) after this (the transform for all the monaco libraries during the build is now gone). |
I looked into this one a bit today. Essentially this is happening because of a circular dependency in Monaco, and the <script>
import { onMount } from 'svelte';
onMount(async () => {
await import('monaco-editor/esm/vs/language/typescript/monaco.contribution.js');
});
</script> And here is my corresponding {
"src/routes/index.svelte": {
"file": "immutable/pages/index.svelte-93e06e99.js",
"src": "src/routes/index.svelte",
"isEntry": true,
"isDynamicEntry": true,
"imports": [
"_preload-helper-96c8edfa.js",
"_index-06f608d5.js"
],
"dynamicImports": [
"_monaco.contribution-0af8d1ea.js"
]
},
"_index-06f608d5.js": {
"file": "immutable/chunks/index-06f608d5.js"
},
"_preload-helper-96c8edfa.js": {
"file": "immutable/chunks/preload-helper-96c8edfa.js"
},
"_monaco.contribution-0af8d1ea.js": {
"file": "immutable/chunks/monaco.contribution-0af8d1ea.js",
"isDynamicEntry": true,
"imports": [
"_preload-helper-96c8edfa.js"
],
"dynamicImports": [
"node_modules/.pnpm/monaco-editor@0.33.0/node_modules/monaco-editor/esm/vs/language/typescript/tsMode.js"
],
"css": [
"immutable/assets/monaco.contribution-9deb5b7b.css"
],
"assets": [
"immutable/assets/codicon-c99115f8.ttf"
]
},
"node_modules/.pnpm/monaco-editor@0.33.0/node_modules/monaco-editor/esm/vs/language/typescript/tsMode.js": {
"file": "immutable/chunks/tsMode-d0fba56e.js",
"src": "node_modules/.pnpm/monaco-editor@0.33.0/node_modules/monaco-editor/esm/vs/language/typescript/tsMode.js",
"isDynamicEntry": true,
"imports": [
"_monaco.contribution-0af8d1ea.js",
"_preload-helper-96c8edfa.js"
]
}
} Here is the traverse('src/routes/index.svelte', true);
traverse('_monaco.contribution.js', false); // Dynamic, not added to imports Set
traverse('tsMode.js', false); // Dynamic, not added to imports Set
traverse('_monaco.contribution.js', false); // Non-dynamic but not added to imports Set because add_js is false
traverse('tsMode.js', false); // Dynamic, not added to imports Set
traverse('_monaco.contribution.js', false); // Non-dynamic but not added to imports Set because add_js is false
traverse('tsMode.js', false); // Dynamic, not added to imports Set
... Since // add_js is true at first so the dynamic import is added to the imports Set for all recursive calls
chunk.dynamicImports.forEach((file) => traverse(file, add_js)); But I don't know if we want to add dynamic imports to the |
* handle circular dependencies in dynamic imports - closes #5399 * add test
Describe the bug
Starting in next.360 my CI/CD build script failed with
[vite-plugin-svelte-kit] Maximum call stack size exceeded
I poked around and found it coming from recurse calls to the
traverse
procedure added apart of #5138I modified the
traverse
function to debugand these where the last few lines.
I had been dynamically importing
monaco-editor
in one my layouts. There are workaround importing via cdnjs however being able to dynamically import it is a lot more desired.Script to reproduce with starter project added below.
Reproduction
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: