Skip to content

Auto preprocess throws on ES6 module scripts #261

Open
@brunnerh

Description

@brunnerh

Describe the bug
When inserting a script in the HTML with type="module", the auto preprocessor will try to load a transformer for it (./transformers/module), which of course does not exist.

To Reproduce

  • Set up auto preprocessing.
  • Process a component like this:
<script></script>

<div>
    <script type="module">
         console.log('!');
    </script>
</div>

Expected behavior
Scripts with type="module" are ignored.

Stacktraces

Stack trace
Error: Cannot find module './transformers/module'
Require stack:
- C:\project\node_modules\svelte-preprocess\dist\autoProcess.js
- C:\project\node_modules\svelte-preprocess\dist\index.js
- C:\project\webpack.config.ts
- C:\project\node_modules\webpack-cli\bin\utils\convert-argv.js
- C:\project\node_modules\webpack-cli\bin\cli.js
- C:\project\node_modules\webpack\bin\webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (C:\project\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
    at C:\project\node_modules\svelte-preprocess\dist\autoProcess.js:35:77
    at Object.exports.runTransformer (C:\project\node_modules\svelte-preprocess\dist\autoProcess.js:35:29)
    at C:\project\node_modules\svelte-preprocess\dist\autoProcess.js:96:29
    at script (C:\project\node_modules\svelte-preprocess\dist\autoProcess.js:121:33)
    at C:\project\node_modules\svelte\src\compiler\preprocess\index.ts:103:23
    at async Promise.all (index 0)
    at replace_async (C:\project\node_modules\svelte\src\compiler\preprocess\index.ts:60:48)
    at preprocess (C:\project\node_modules\svelte\src\compiler\preprocess\index.ts:95:12)
 @ ./src/test.ts 1:0-39 2:16-23

Information about your project:

  • Your operating system: Windows 10 64bit
  • svelte-preprocess version: 4.3.2
  • Whether your project uses Webpack or Rollup: Webpack

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions