Skip to content

Commit ed4066d

Browse files
committed
fix: Change the magic comment to be more clearly css-blocks related.
1 parent be74160 commit ed4066d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

rfcs/rfc-ember-integration-v2.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This project will be successful if it meets the following criteria:
3131
* Has a clear, testable contract between addon output and application inputs, including support and test matrices for older instances of CSS Blocks code.
3232
* Works well with addons that are using `yarn link` to develop in tandem with an application.
3333
* Unblock the planned "Block Passing" capability.
34+
* Both lazy and eager engines are working.
3435

3536
# Summary of Architectural Changes
3637

@@ -90,17 +91,17 @@ The goal of the compiled Block CSS file format is to
9091
A compiled block takes the following basic form:
9192

9293
```css
93-
/*#opticss-analyzed-styles-start:<block-id>*/
94+
/*#css-blocks <block-id>*/
9495
... compiled output ...
95-
/*#opticss-analyzed-styles-end:<block-id>*/
9696
/*#blockDefinitionURL=pathToBlockDefinitionFile.block*/
97+
/*#css-blocks end*/
9798
```
9899

99100
There's three magic comments, let's walk through what they do:
100101

101-
* `/*#opticss-analyzed-styles-start:<block-id>*/` &mdash; Indicates that the CSS that follows has been statically analyzed and is eligible for optimization by opticss. The block id must be 128 bytes or fewer.
102-
* `/*#opticss-analyzed-styles-end:<block-id>*/` &mdash; must be followed by the same id as a prior `opticss-analyzed-styles-start`
102+
* `/*#css-blocks <block-id>*/` &mdash; Indicates that the CSS that follows has been statically analyzed compiled by css-blocks. The block id must be 128 bytes or fewer.
103103
* `/*#blockDefinitionURL=pathToBlockDefinitionFile.block*/` &mdash; relative path to a block definition file or an inline url containing a base64 encoded file contents. The form of an inline URL for a block definition file is `/*#blockDefinitionURL=data:text/css;charset=utf-8;base64,<encoded-data>*/`.
104+
* `/*#css-blocks end*/` &mdash; marks the end of content compiled by css blocks.
104105

105106
Additionally, the compiled output file may have a magic comment for an associated sourcemap.
106107

@@ -113,7 +114,7 @@ The block definition file can be considered a serialization of the parsed Block'
113114
The block definition file differs from the source file in the following ways:
114115

115116
* `@block`, `@export` &mdash; The path to the block file is now the relative path to the file that the block was compiled to.
116-
* `:scope` &mdash; A block-specific declaration of `block-id` with a quoted string value of the block's unique identifier (this id will match the block-id associated with the `opticss-analyzed-styles-(start|end)` comments)
117+
* `:scope` &mdash; A block-specific declaration of `block-id` with a quoted string value of the block's unique identifier (this id will match the block-id associated with the `css-blocks <block-id>` comment)
117118
* `resolve()` declarations &mdash; The value of the block's declaration is now stored in the css file. In the definition file we replace this block's declaration's value with `resolve-self()` to indicate the relative precedence of that block.
118119
* `@block-debug` at-rules are processed during compilation and removed.
119120
* `block-class` &mdash; This block declaration is only valid in a definition file. Each block style will have the CSS class name to which it was compiled set explicitly. These names might differ from the names that would be generated by the options the current process is using.
@@ -162,7 +163,7 @@ Consider the following source file:
162163
It would compile to:
163164

164165
```css
165-
/*#opticss-analyzed-styles-start:7d97e*/
166+
/*#css-blocks 7d97e*/
166167
.nav-7d97e {
167168
display: flex;
168169
}
@@ -178,8 +179,8 @@ It would compile to:
178179
.nav-7d97e__entry:hover {
179180
text-shadow: 2px 2px 1px;
180181
}
181-
/*#opticss-analyzed-styles-end:7d97e*/
182182
/*#blockDefinitionURL=nav.block*/
183+
/*#css-blocks end*/
183184
```
184185

185186
And to the following definition file:
@@ -265,7 +266,7 @@ the files from the addons.
265266

266267
This addon will install a broccoli plugin that performs the following actions:
267268

268-
1. Find CSS files that contain `/*#opticss-analyzed-styles-start:<block-id>*/` on the first line (because the block-id has a max length, we need only read the first 164 bytes of the file). If the magic comment is present and the block-id has not been encountered, read the whole file and it to the optimizer. If the block-id has been seen already, discard it. Don't transfer any files that were compiled from css-blocks to the output tree. (Note: We probably need to parse these compiled block files back into blocks, but we might be able to avoid it in the future.)
269+
1. Find CSS files that contain `/*#css-blocks <block-id>*/` on the first line (because the block-id has a max length, we need only read the first 144 bytes of the file). If the magic comment is present and the block-id has not been encountered, read the whole file and it to the optimizer. If the block-id has been seen already, discard it. Don't transfer any files that were compiled from css-blocks to the output tree. (Note: We probably need to parse these compiled block files back into blocks, but we might be able to avoid it in the future.)
269270
2. Find all the serialized template analysis files, deserialize them and add them to the optimizer. Don't transfer the template analysis files to the output tree.
270271
3. Run the optimizer and write the optimized stylesheet to a single CSS file in the application's styles directory (css-blocks.css). (Note: This file should be concatenated with the applications' other stylesheets. It should come after any resets and before any non-css-blocks styles.)
271272
4. Produce the data file that the css-blocks runtime helper will use to rewrite styles for each element. TODO: Figure out how to best get that file into the application bundle. We might need use the `app.postProcessTree('all')` hook to inject a "define" into the file into the application's JS bundle.

0 commit comments

Comments
 (0)