Skip to content

markup syntax error throws parse exception, crashing entire webpack watch process #438

@elirov

Description

@elirov

Describe the bug
Any html markup error in the component causes the parser to throw a fatal error, which crashes webpack watch, necessitating a full restart of the process.

Logs
ERROR in ./tmpls/patient-intake/components/sections/Insurance.svelte
Module build failed (from ./node_modules/svelte-loader/index.js):
ParseError: Unexpected token
at error (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/utils/error.ts:25:16)
at Parser$1.error (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/parse/index.ts:101:3)
at Parser$1.acorn_error (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/parse/index.ts:94:8)
at read_expression (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/parse/read/expression.ts:34:10)
at mustache (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/parse/state/mustache.ts:379:22)
at new Parser$1 (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/parse/index.ts:53:12)
at parse (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/parse/index.ts:218:17)
at compile (/Users/elirov/workspace/xdocs/node_modules/svelte/src/compiler/compile/index.ts:94:14)
at injectVarsToCode (/Users/elirov/workspace/xdocs/node_modules/svelte-preprocess/dist/transformers/typescript.js:71:45)
at mixedImportsTranspiler (/Users/elirov/workspace/xdocs/node_modules/svelte-preprocess/dist/transformers/typescript.js:225:26)
@ ./tmpls/patient-intake/components/NewPatientView.svelte 23:0-52 60:17-26 215:2-11
@ ./tmpls/patient-intake/components/MainLayout.svelte 25:0-53 164:22-36 661:2-16
@ ./tmpls/patient-intake/init.js 16:0-69 29:35-45
@ ./src/client/dev/main.js 10:0-61 17:2-16

webpack 5.64.4 compiled with 1 error in 8794 ms
node:internal/validators:120
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^

TypeError: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:371:5)
at validateString (node:internal/validators:120:11)
at Object.dirname (node:path:1276:5)
at WatcherManager.watchFile (/Users/elirov/workspace/xdocs/node_modules/watchpack/lib/getWatcherManager.js:30:26)
at /Users/elirov/workspace/xdocs/node_modules/watchpack/lib/watchpack.js:280:41
at Object.exports.batch (/Users/elirov/workspace/xdocs/node_modules/watchpack/lib/watchEventSource.js:326:3)
at Watchpack.watch (/Users/elirov/workspace/xdocs/node_modules/watchpack/lib/watchpack.js:278:20)
at NodeWatchFileSystem.watch (/Users/elirov/workspace/xdocs/node_modules/webpack/lib/node/NodeWatchFileSystem.js:107:16)
at Watching.watch (/Users/elirov/workspace/xdocs/node_modules/webpack/lib/Watching.js:325:48)
at /Users/elirov/workspace/xdocs/node_modules/webpack/lib/Watching.js:303:13 {
code: 'ERR_INVALID_ARG_TYPE'
}

To Reproduce
Create a svelte component with something like this in the markup section:
{if<div/>

Expected behavior
Should not throw a fatal error - just output anything so that the watch process can stay up (similarly to what happens if you have a syntax error in the <script> part of the svelte file.

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)

  • macos

  • svelte-preprocess version (Please check you can reproduce the issue with the latest release!)

  • 4.9.8

  • Whether your project uses Webpack or Rollup

  • webpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions