originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.3k stars 236 forks source link

reports SyntaxError when there is a style tag in html file #371

Open tcstory opened 1 year ago

tcstory commented 1 year ago

Versions

Reproduction

https://github.com/tcstory/vue3-demo-esm-bug

Steps to reproduce

  1. npm install
  2. npm run dev
  3. visit http://127.0.0.1:5001/index.html

What is Expected?

no error is reported on terminal

What is actually happening?

you will see the following error. but if you remove the style tag from the index.html, the problem will be solved.


  1 SyntaxError: Unexpected token (2:15)
  2     at Parser.pp$4.raise (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:18300:13)
  3     at Parser.pp$9.unexpected (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:15601:8)
  4     at Parser.pp$9.semicolon (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:15578:66)
  5     at Parser.pp$8.parseExpressionStatement (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:16061:8)
  6     at Parser.pp$8.parseStatement (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:15794:24)
  7     at Parser.pp$8.parseTopLevel (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:15658:21)
  8     at Parser.parse (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:15430:15)
  9     at Function.parse (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:15480:35)
 10     at TransformContext.parse (file:///home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/vite/dist/node/chunks/dep-ca21228b.js:41350:27)
 11     at TransformContext.transform (/home/xxxx/Desktop/vue3-demo-esm-bug/node_modules/@originjs/vite-plugin-federation/dist/index.js:1180:20) {
 12   pos: 16,
 13   loc: Position { line: 2, column: 15 },
 14   raisedAt: 17
 15 }
ruleeeer commented 1 year ago

It seems that the error is caused by the ast conversion of some not js related files.