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

Update browser runtime #409

Merged
merged 29 commits into from
Oct 12, 2021
Merged

Update browser runtime #409

merged 29 commits into from
Oct 12, 2021

Conversation

benjervis
Copy link

Primarily moving to the new vanilla runtime.

Also includes a bunch of bugfixes especially around the vite plugin.

@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2021

🦋 Changeset detected

Latest commit: 8b18442

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@vanilla-extract/vite-plugin Patch
@vanilla-extract/css Patch
@vanilla-extract/babel-plugin Patch
@vanilla-extract/integration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

.changeset/khaki-taxis-tell.md Outdated Show resolved Hide resolved
.changeset/polite-rings-nail.md Outdated Show resolved Hide resolved
@@ -15,7 +15,8 @@
"author": "SEEK",
"license": "MIT",
"dependencies": {
"@vanilla-extract/integration": "^1.4.2"
"@vanilla-extract/integration": "^1.4.2",
"outdent": "^0.8.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Realised we're already using dedent in the css package so we should probably be consistent.

@@ -3,6 +3,7 @@
"version": "1.4.2",
"description": "Zero-runtime Stylesheets-in-TypeScript",
"main": "dist/vanilla-extract-integration.cjs.js",
"module": "dist/vanilla-extract-integration.esm.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't required anymore.

processVanillaFile,
parseFileScope,
stringifyFileScope,
} from './processVanillaFile';
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to add a changeset for the integration package

if (extensionIndex > 0) {
const fileScopeId = id.substring(0, extensionIndex);

if (cssMap.has(fileScopeId)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should throw an explicit error if this condition is false. It should never really occur yeah?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah that makes sense, I don't think it should be false ever.


if (ssr || useRuntime) {
if (ssr) {
const validId = id.substring(0, id.indexOf('?'));
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be resilient to strings that don't have a query attached.

packageInfo,
}).source;
}

const { source, watchFiles } = await compile({
filePath: fixedId,
filePath: id,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should continue to strip the query if it has one, just to be sure there's no funny business.

cwd: config.root,
});

for (const file of watchFiles) {
this.addWatchFile(file);
if (config.command === 'build' || file !== id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding a comment as to why we have the config.command === 'build' check.

}

return processVanillaFile({
source,
filePath: fixedId,
outputCss: !ssr,
filePath: id,
Copy link
Contributor

Choose a reason for hiding this comment

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

Think we should continue to strip the query here as well.


injectStyles({
fileScope: ${JSON.stringify(fileScope)},
css: ${JSON.stringify(css)}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be borking the screenshot tests due to the newline encoding

Copy link
Contributor

@mattcompiles mattcompiles left a comment

Choose a reason for hiding this comment

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

Nice one 👏

@benjervis benjervis merged commit a9c5cb7 into master Oct 12, 2021
@benjervis benjervis deleted the inject branch October 12, 2021 23:33
@seek-oss-ci seek-oss-ci mentioned this pull request Oct 12, 2021
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.

2 participants