-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Conversation
… from turning them into a default export, reorder plugins
…syntax to mount test app
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 🤔
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.
I think it's fine to leave it as is. If I wanted to find out how dependencies were being handled, I would intuitively look at the compile plugin file rather than preprocess, so that's one reason to keep it as is.
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.
thing is that dependencies are really a preprocessor thing, the compiler always only looks at the input svelte code and assumes it to come from one file (except the input sourcemap can reference multiple files but the compiler doesn't use that for changing the output in any way)
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.
either way thats for a follow-up PR
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.
Oh interesting. So it should really be in the preprocess plugin, that way if it were ever removed, you wouldn't have to fiddle with the compile file?
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.
this grew rather large but sharing for better discussion
goals:
Todo: