LearnNewsExamplesServices
Frontmatter
id9517
titleWorkers: Standardize and optimize dynamic imports
stateClosed
labels
airefactoringbuildcore
assigneestobiu
createdAtMar 19, 2026, 11:11 AM
updatedAtMar 19, 2026, 11:17 AM
githubUrlhttps://github.com/neomjs/neo/issues/9517
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 19, 2026, 11:17 AM

Workers: Standardize and optimize dynamic imports

Closed v12.1.0 airefactoringbuildcore
tobiu
tobiu commented on Mar 19, 2026, 11:11 AM

Standardize the dynamic import() pattern across all workers (App, Canvas, Data, Task) to improve build stability and performance.

Changes:

  1. Extension Handling: Adopt the pattern of stripping .mjs from the input path and adding it explicitly in the template literal (../../${path}.mjs). This provides Webpack with a clearer file extension hint.
  2. webpackInclude Optimization: Restrict Webpack's search scope to relevant source directories: apps, docs/app, examples, and src. This prevents Webpack from parsing high-volume or incompatible directories like resources, test, or SCSS folders.
  3. Standardized webpackExclude: Use a consistent exclusion pattern for buildScripts, dist, and node_modules.

Regex Patterns:

  • Generic modules (Data): /^(?:apps|docs\/app|examples|src)\/.*\.mjs$/
  • App entry points (App): /^(?:apps|docs\/app|examples|src)\/.*app\.mjs$/
  • Worker-specific modules (Canvas): /^(?:apps|examples|src)\/.*canvas\/.*\.mjs$/
  • Worker initialization (Canvas/Task): /^(?:apps|examples|src)\/.*\/canvas\.mjs$/ (or task.mjs)

This resolves build crashes where Webpack attempts to parse non-JavaScript files discovered through overly broad dynamic import contexts.

tobiu added the ai label on Mar 19, 2026, 11:11 AM
tobiu added the refactoring label on Mar 19, 2026, 11:11 AM
tobiu added the build label on Mar 19, 2026, 11:11 AM
tobiu added the core label on Mar 19, 2026, 11:11 AM
tobiu referenced in commit 0eae36c - "refactor: Workers: Standardize and optimize dynamic imports (#9517)" on Mar 19, 2026, 11:16 AM
tobiu assigned to @tobiu on Mar 19, 2026, 11:16 AM
tobiu
tobiu Mar 19, 2026, 11:17 AM

Input from Gemini 3.1 Pro:

✦ The dynamic import() pattern has been standardized and optimized across all workers (App, Canvas, Data, Task).

Key changes:

  • Restricted webpackInclude to apps, docs/app, examples, and src.
  • Added .mjs extension stripping/adding in template literals for clearer Webpack hints.
  • Standardized webpackExclude across all workers.

This ensures Webpack only parses relevant source files, preventing build crashes caused by incompatible or high-volume non-JS directories.

tobiu closed this issue on Mar 19, 2026, 11:17 AM