Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support thread loader by optional inline emitCss (base64, querystring)#164

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
non25 wants to merge4 commits intosveltejs:master
base:master
Choose a base branch
Loading
fromnon25:optional-emitcss-inline

Conversation

non25
Copy link
Contributor

This option makes svelte-loader output base64'd css in querystring, which is always available to any thread.
It is turned off by default because it pollutes webpack's console output, but if user needs to use thread-loader, he can.

@@ -272,6 +272,29 @@ module.exports = {
}
```

## Using svelte-loader in combination with thread-loader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Would this feature be useful in other cases? (e.g. I think you mentioned tailwind and babel). If so, can we describe this feature more generically? I'm find mentioningthread-loader, but it maybe shouldn't be the focus

Copy link
ContributorAuthor

@non25non25Jan 17, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I can't think of other cases... It is mainly useful because it allows other processess/workers to get css reliably, and not try to access an empty Map.
The default Map storage with file paths in a query will only be accessible in that exact process.
@trash-and-fire told me that we can detect ifthread-loader is used in a pipeline withsvelte-loader and turn this on automatically.
Maybe we should make it that way.. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That might be nicer than adding an option. But I also wonder if it's even worth adding something that's only useful forthread-loader

Copy link
ContributorAuthor

@non25non25Jan 17, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Part of the reason I'm here is because one day one man tried to usesvelte-loader withtailwindcss throughsvelte-preprocess and had 4 mins of build-time and 40 seconds of reload time for 20 or so components. 😁
That would save him.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does that mean that you need to usethread-loader to deal withsveltejs/svelte-preprocess#275 ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Exactly. It will speed up that thing significantly.
But you also need to configure preprocess and webpack.css pipeline correctly to gain maximum performance.

Copy link

@trash-and-firetrash-and-fireJan 17, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this is not an entirely accurate statement.

There was a problem of rebuilding all virtual css files if only one changed. This issue has been fixed without using a thread loader. A thread loader can provide additional performance by parallelizing the compilation of each file into a process pool. But there is no shared memory between processes, we must transfer all the content of the css file through the import line.

non25 reacted with eyes emoji
@non25
Copy link
ContributorAuthor

Now it checks automatically.this.emitFile is not available in loaders spawned bythread-loader, so I'm using that.

@@ -62,10 +65,17 @@ module.exports = function(source, map) {

if (options.emitCss && css.code) {
const resource = posixify(compileOptions.filename);
const cssPath = `${resource}.${index++}.css`;
const threadLoaderUsed = this.emitFile === undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps there should be an override to force inline mode to always be enabled or disabled? (this could be written asoptions.forceInlineCss ?? this.emitFile === undefined in Node 14+ but alas versions below thatdon't support the?? operator)

Suggested change
constthreadLoaderUsed=this.emitFile===undefined;
constthreadLoaderUsed=(options.forceInlineCss===undefined) ?this.emitFile===undefined :options.forceInlineCss;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's a reasonable suggestion, but the downside is that the option then becomes part of the API, which makes it hard to change (we'd need another major release). I might wait until a need for it arises to leave us more flexibility instead of adding it up front

@non25
Copy link
ContributorAuthor

So what do you think guys?
I think adding this feature could be helpful. In default webpack configs it won't do anything, but people can start to experiment withthread-loader andtailwindcss and try to get better results in dev mode cold starts and in prod mode.
If it would appear to be useless then we can safely remove it, because no API changes were made.

@non25non25force-pushed theoptional-emitcss-inline branch from6680419 toe353a4cCompareJanuary 19, 2021 05:52
@non25
Copy link
ContributorAuthor

Interesting, it doesn't work withsvelte-preprocess. I decided to try it with my scss preprocessed project and it tells me this stuff:

Thread Loader (Worker 0)ParseError: Unexpected input (19:22)17:   .button {18:     $bgcol: hsl(215, 35%, 50%);19:     background-color: $bgcol;                          ^20:     border: pxrem(1) solid mix(#000, $bgcol, 14);21:     border-radius: pxrem(5);

So I guess we will release without this PR.

@syvbsyvb mentioned this pull requestJan 21, 2021
This option makes svelte-loader output base64'd css in querystring,which is always available to any thread.It is turned off by default because it pollutes webpack's consoleoutput, but if user needs to use thread-loader, he can.
this.emitFile is not available in test mocks, so we need to check forcssData instead of cssPath
@non25non25force-pushed theoptional-emitcss-inline branch frome353a4c tob2ca22cCompareApril 14, 2021 09:32
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@benmccannbenmccannbenmccann left review comments

@syvbsyvbsyvb left review comments

@trash-and-firetrash-and-firetrash-and-fire left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@non25@benmccann@syvb@trash-and-fire

[8]ページ先頭

©2009-2025 Movatter.jp