-
-
Notifications
You must be signed in to change notification settings - Fork 116
refactor: modular plugins #1145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… from turning them into a default export, reorder plugins
…syntax to mount test app
if (compileData.compiled?.warnings) { | ||
logCompilerWarnings(svelteRequest, compileData.compiled.warnings, options); | ||
} | ||
if (svelteRequest.raw) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this block of code is for an experimental feature returning data for import queries like App.svelte?raw&svelte&type=script
, however that feature has remained unused for a long time.
with the split between preprocess & compile it got more complicated to support it so i propose to remove the feature entirely and only keep basic "raw" support from vite that returns the non-transformed file.
const svelteRequest = api.idParser(id, ssr); | ||
if (svelteRequest) { | ||
const { filename, raw, query } = svelteRequest; | ||
if (!query.url && (raw || config.assetsInclude(filename))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the check for raw
here is needed for the custom import query support
map: preprocessed.map, | ||
meta: { | ||
svelte: { | ||
preprocessed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attach the preprocess result to module meta so svelte.compile can get the dependencies and sourcemap.
should the dependencies handling be moved into this plugin instead? sourcemap in compile could be inMap then 🤔
if (closeStylePos > -1) { | ||
// inject rule that forces compile to attach scope class to every node in the template | ||
// this reduces the amount of js hot updates when editing css in .svelte files | ||
finalCode = finalCode.slice(0, closeStylePos) + ' *{}' + finalCode.slice(closeStylePos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this used to be a style preprocessor, however that made the preprocess plugin more complicated. Just slicing it in behind the last closing style tag is much less overhead.
It could break in dev if someone were to have a literal close style tag after the actual close style tag. Is that acceptable?
<style>div{color: red}</style>
<div>{'</style>'}</div>
for (let i = 0; i < svelteModules.length; i++) { | ||
const mod = svelteModules[i]; | ||
const prev = prevResults[i]; | ||
await this.environment.transformRequest(mod.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transform the module again so we get the output including preprocess plugin and third party plugin changes.
the previous implementation called our compile helper that preprocessed and compiled according to svelte config but that would not account for the new preprocess plugin or third party plugins.
// svelte5 add_location line numbers argument | ||
.replace(/(\$\.add_locations\(.*), \[(\[[.[\], \d]+])]/g, '$1, []') | ||
// vite import analysis timestamp queries | ||
.replace(/[?&]t=\d+/g, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is \d+
ok or should it be more targeted eg \d{13}[&\b]
?
this grew rather large but sharing for better discussion
goals:
Todo: