Skip to content
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

Remove codicon.css, document and explain future usage #312

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

kaisalmen
Copy link
Contributor

  • This removes the need to have codicon as depedency to the sprotty core
  • Replace rimraf wih shx along the way

This is the proposed solution for #311

Copy link
Contributor

@spoenemann spoenemann left a comment

Choose a reason for hiding this comment

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

I'm ok with the changes (but see comments below). @ndoschek @planger @tortmayr please have a look as well.

This brings up a more general question to me regarding the original introduction of the codicons dependency in #249: Shouldn't this be a dependency of the concrete application or downstream library rather than the core package? The sprotty package itself does not need this dependency, only the applications that want to include such icons do. A lot of users of the sprotty package do not need codicons. Would it be feasible to drop the dependency and leave it to the responsibility of the package users to bundle the icons if they need them?

@@ -0,0 +1,16 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

The build script is not very large. I'd propose to write it as a .js file with // @ts-check annotation so there's no need for a separate tsc call and config file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is a good idea, plus the "debug" functionality (generateAlernateLoadingFunction and storage in separate files) could be removed, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Transformed it to JavaScript and removed everything unnecessary.

const ttfData = `data:font/ttf;base64,${dataTtf}`;
const alteredCssData = cssData.replace('"./codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa"', ttfData);

fs.writeFileSync('./css/generated/codicon.css', alteredCssData);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a redistribution of the codicon content and so we need to attribute that correctly according to their license:

https://github.com/microsoft/vscode-codicons/blob/e7d905a9cb4f06a0d4c4c93279967734faf66f0f/LICENSE#L217-L244

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thank you, I didn't check that, yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The generated CSS contains links to both license and the original Microsoft Copyright header. There must be some mentioning of codicon usage in the README. Should I add that?

@tortmayr
Copy link
Contributor

This brings up a more general question to me regarding the original introduction of the codicons dependency in #249: Shouldn't this be a dependency of the concrete application or downstream library rather than the core package? The sprotty package itself does not need this dependency, only the applications that want to include such icons do. A lot of users of the sprotty package do not need codicons. Would it be feasible to drop the dependency and leave it to the responsibility of the package users to bundle the icons if they need them?

In general, I agree this probably should be a dependency of the downstream project. This way the consuming project/library could is also in complete control of the codicon version that should be used.

The sprotty package itself does not need this dependency, only the applications that want to include such icons do.

That's currently not completely true. It seems like default implementation of the command palette is currently using codicons.
So we should probably refactor this or at least mention in the ts doc that codicon is needed for the command palette feature.

@spoenemann
Copy link
Contributor

@tortmayr @planger so shall we work towards getting rid of the codicons dependency in the core package? Of course this needs to be well documented in the CHANGELOG, but it sounds viable to me.

@spoenemann
Copy link
Contributor

@tortmayr ping

@kaisalmen
Copy link
Contributor Author

kaisalmen commented Nov 28, 2022

I have squashed and force pushed the branch on current main and performed a bit of clean-up.

We could use this workaround/solution for now until we find a potential better solution. It would help prevent for example this problem: #311 (comment)

Copy link
Contributor

@spoenemann spoenemann left a comment

Choose a reason for hiding this comment

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

I think we can go right to the cleaner solution instead of introducing a workaround.

My proposal:

@kaisalmen
Copy link
Contributor Author

Ok, in addition I will apply add the codicon css to the classdiagram example. Then it it is not only documented, but people can see how it is actually done (we can even reference that from the CHANGELOG).

@tortmayr
Copy link
Contributor

@spoenemann Sorry for the late reply. The proposed changes look good to me 👍🏼

@kaisalmen kaisalmen changed the title Use generate codicon.css with embedded TTF instead of imported one Remove codicon.css, document and explain future usage Dec 5, 2022
@kaisalmen
Copy link
Contributor Author

@spoenemann The rework is done. This is now ready for review. I fought with the webpack config, beacuse codicon.ttf was not loaded. In the end, removing the extra config removed the problem. webpack 5 (introduced in between initial addition of command palette) changed asset handling.

Copy link
Contributor

@spoenemann spoenemann left a comment

Choose a reason for hiding this comment

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

Thank You!

@spoenemann spoenemann merged commit fc3187b into eclipse-sprotty:master Dec 6, 2022
@kaisalmen kaisalmen deleted the codicon-transform branch December 6, 2022 16:31
@spoenemann spoenemann added this to the v0.13.0 milestone Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants