question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unexpected ?import added to plugin IDs

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)

Describe the bug

I have a regex that looks for files ending in .svelte as suggested by the documentation here: https://vitejs.dev/guide/api-plugin.html#transforming-custom-file-types

That regex fails because ?import is added to the end of files. I believe that the ?import addition is a bug, but it’s possible the documentation needs to be updated instead

Reproduction

git clone git@github.com:benmccann/vite-svelte.git
npm install
npm run build
node server

Then visit http://localhost:3000

This will print:

load called with unexpected id /home/bmccann/src/vite-svelte/src/App.svelte?import
transform called with unexpected id /home/bmccann/src/vite-svelte/src/App.svelte?import

I put debug statements in the plugin here: https://github.com/benmccann/vite-plugin-svelte/blob/be10f3b71f7e440dea8a8b644a15a12c97f0df7d/index.js#L105

You should be able to edit the code in node_modules/vite-plugin-svelte/index.js if you want to futz around further

System Info

  • vite version: 2.0.0-beta.36
  • Operating System: Ubuntu
  • Node version: 14.8.0
  • Package manager (npm/yarn/pnpm) and version: npm 6.14.11

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
benmccanncommented, Jan 23, 2021

Amazing! Thank you!

Would it make any sense for this plugin to live in https://github.com/vitejs/vite/tree/main/packages after I clean it up?

Also, you had mentioned earlier that I might need to handle CSS differently than rollup-plugin-svelte does. Is there anything in particular I should be on the lookout for there?

0reactions
yyx990803commented, Jan 23, 2021

Cool!

Re package placement: depends on the ownership - putting it inside vite’s repo would mean we are committed to maintaining it, which isn’t the case, so I think it makes more sense to maybe put it in the Svelte org?

Re CSS: during dev, what Vue is doing is generating an import to a virtual module like this:

import '/path/to/Component.vue?vue&type=style&lang=.css'

The plugin would then check for this request in load and return the previously compiled CSS. This leverages Vite’s internal CSS handling for everything, including HMR, PostCSS configs, pre-processors (with &lang=.scss) and CSS modules (with &lang=.module.css).

I think that’s kind of what the Svelte plugin is doing but from my previous simple try HMR was not working for CSS, maybe you can figure it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugin missing for node actions [#3045570] | Drupal.org
I get the following error during config import: The import failed due to the following reasons Unexpected error during import with operation ...
Read more >
Babel loader unable to handle Imports - give syntaxError
Problem: So my app loads but my imports fail to work giving me errors such as Uncaught SyntaxError: Unexpected token, or unexpected ...
Read more >
Unexpected error during import . . . plugin does not exist error ...
I was able to solve this with an update hook. By deleting the config and then reimporting it this way, it doesn't trigger...
Read more >
Gradle Kotlin DSL Primer
Add a plugin repository to the build's settings script. Map the plugin ID to the corresponding artifact coordinates. You accomplish both steps by...
Read more >
Framework: Resource Import | Terraform - HashiCorp Developer
How to support resource import using the provider development framework. ... has the id attribute set to the value passed into the terraform...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found