Skip to content

Commit e590571

Browse files
committed
fix($html): removed wrapping spans in strings and removed IDs for React component spans
1 parent 6504859 commit e590571

File tree

5 files changed

+38
-59
lines changed

5 files changed

+38
-59
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
__fixtures__
2+
.babelrc
3+
.codeclimate.yml
4+
.editorconfig
5+
.eslintrc.js
6+
.snyk
7+
.travis.yml
8+
wallaby.js
9+
webpack.config.js
10+
*.log
11+
.vscode/
212
__tests__
13+
coverage
314
src

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Because of the way Webpack works where "bootstrap" code must be run before any a
118118
it's imperative bootstrap and common chunks are generated and placed at the beginning,
119119
thereby allowing you to place dynamic chunks before your entry chunk which kickstarts app rendering.
120120

121-
In conjunction with your Webpack configuration (which we'll specify below), `flushChunks` solves these problems for you by consuming your Webpack compilation `stats` and generating strings and components you can embed in the final output rendered on the server.
121+
In conjunction with your Webpack configuration (which we'll specify [below](#webpack-configuration)), `flushChunks` solves these problems for you by consuming your Webpack compilation `stats` and generating strings and components you can embed in the final output rendered on the server.
122122

123123
## Usage
124124

__tests__/__snapshots__/createApiWithCss.test.js.snap

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`createApiWithCss() generates js + style components, strings and arrays 1`] = `
4-
<span
5-
id="__javascript__"
6-
>
4+
<span>
75
<script
86
src="/static/0.js"
97
type="text/javascript"
@@ -16,9 +14,7 @@ exports[`createApiWithCss() generates js + style components, strings and arrays
1614
`;
1715

1816
exports[`createApiWithCss() generates js + style components, strings and arrays 2`] = `
19-
<span
20-
id="__styles__"
21-
>
17+
<span>
2218
<link
2319
href="/static/0.css"
2420
rel="stylesheet"
@@ -31,9 +27,7 @@ exports[`createApiWithCss() generates js + style components, strings and arrays
3127
`;
3228

3329
exports[`createApiWithCss() generates js + style components, strings and arrays 3`] = `
34-
<span
35-
id="__styles__"
36-
>
30+
<span>
3731
<style>
3832
/Users/jamesgillmore/App/build/0.css- the css!
3933
@@ -44,26 +38,20 @@ exports[`createApiWithCss() generates js + style components, strings and arrays
4438
`;
4539

4640
exports[`createApiWithCss() generates js + style components, strings and arrays 4`] = `
47-
"<span id='__javascript__'>
48-
<script type='text/javascript' src='/static/0.js'></script>
49-
<script type='text/javascript' src='/static/main.js'></script>
50-
</span>"
41+
"<script type='text/javascript' src='/static/0.js'></script>
42+
<script type='text/javascript' src='/static/main.js'></script>"
5143
`;
5244

5345
exports[`createApiWithCss() generates js + style components, strings and arrays 5`] = `
54-
"<span id='__styles__'>
55-
<link rel='stylesheet' href='/static/0.css' />
56-
<link rel='stylesheet' href='/static/main.css' />
57-
</span>"
46+
"<link rel='stylesheet' href='/static/0.css' />
47+
<link rel='stylesheet' href='/static/main.css' />"
5848
`;
5949

6050
exports[`createApiWithCss() generates js + style components, strings and arrays 6`] = `
61-
"<span id='__styles__'>
62-
<style>/Users/jamesgillmore/App/build/0.css- the css!
51+
"<style>/Users/jamesgillmore/App/build/0.css- the css!
6352
6453
/Users/jamesgillmore/App/build/main.css- the css!
65-
</style>
66-
</span>"
54+
</style>"
6755
`;
6856

6957
exports[`createApiWithCss() generates js + style components, strings and arrays 7`] = `
@@ -81,9 +69,7 @@ Array [
8169
`;
8270

8371
exports[`createApiWithCss() uses files with extension "no_css.js" if available 1`] = `
84-
<span
85-
id="__javascript__"
86-
>
72+
<span>
8773
<script
8874
src="/static/main.no_css.js"
8975
type="text/javascript"
@@ -92,9 +78,7 @@ exports[`createApiWithCss() uses files with extension "no_css.js" if available 1
9278
`;
9379

9480
exports[`createApiWithCss() uses files with extension "no_css.js" if available 2`] = `
95-
<span
96-
id="__styles__"
97-
>
81+
<span>
9882
<link
9983
href="/static/main.css"
10084
rel="stylesheet"
@@ -103,33 +87,21 @@ exports[`createApiWithCss() uses files with extension "no_css.js" if available 2
10387
`;
10488

10589
exports[`createApiWithCss() uses files with extension "no_css.js" if available 3`] = `
106-
<span
107-
id="__styles__"
108-
>
90+
<span>
10991
<style>
11092
/Users/jamesgillmore/App/build/main.css- the css!
11193
11294
</style>
11395
</span>
11496
`;
11597

116-
exports[`createApiWithCss() uses files with extension "no_css.js" if available 4`] = `
117-
"<span id='__javascript__'>
118-
<script type='text/javascript' src='/static/main.no_css.js'></script>
119-
</span>"
120-
`;
98+
exports[`createApiWithCss() uses files with extension "no_css.js" if available 4`] = `"<script type='text/javascript' src='/static/main.no_css.js'></script>"`;
12199

122-
exports[`createApiWithCss() uses files with extension "no_css.js" if available 5`] = `
123-
"<span id='__styles__'>
124-
<link rel='stylesheet' href='/static/main.css' />
125-
</span>"
126-
`;
100+
exports[`createApiWithCss() uses files with extension "no_css.js" if available 5`] = `"<link rel='stylesheet' href='/static/main.css' />"`;
127101

128102
exports[`createApiWithCss() uses files with extension "no_css.js" if available 6`] = `
129-
"<span id='__styles__'>
130-
<style>/Users/jamesgillmore/App/build/main.css- the css!
131-
</style>
132-
</span>"
103+
"<style>/Users/jamesgillmore/App/build/main.css- the css!
104+
</style>"
133105
`;
134106

135107
exports[`createApiWithCss() uses files with extension "no_css.js" if available 7`] = `

src/createApiWithCss.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default (
4040
// 1) Use as React components using ReactDOM.renderToStaticMarkup, eg:
4141
// <html><Styles /><Js /><html>
4242
Js: () => (
43-
<span id='__javascript__'>
43+
<span>
4444
{scripts.map((file, key) => (
4545
<script
4646
type='text/javascript'
@@ -51,7 +51,7 @@ export default (
5151
</span>
5252
),
5353
Styles: () => (
54-
<span id='__styles__'>
54+
<span>
5555
{stylesheets.map((file, key) => (
5656
<link rel='stylesheet' href={`${publicPath}/${file}`} key={key} />
5757
))}
@@ -62,23 +62,19 @@ export default (
6262
js: {
6363
toString: () =>
6464
// lazy-loaded in case not used
65-
`<span id='__javascript__'>
66-
${scripts
65+
scripts
6766
.map(
6867
file =>
6968
`<script type='text/javascript' src='${publicPath}/${file}'></script>`
7069
)
71-
.join('\n')}
72-
</span>`
70+
.join('\n')
7371
},
7472
styles: {
7573
toString: () =>
7674
// lazy-loaded in case not used
77-
`<span id='__styles__'>
78-
${stylesheets
75+
stylesheets
7976
.map(file => `<link rel='stylesheet' href='${publicPath}/${file}' />`)
80-
.join('\n')}
81-
</span>`
77+
.join('\n')
8278
},
8379

8480
// 3) Embed the raw css without needing to load another file.
@@ -87,17 +83,15 @@ export default (
8783
Css: () =>
8884
(DEV
8985
? api.Styles()
90-
: <span id='__styles__'>
86+
: <span>
9187
<style>{stylesAsString(stylesheets, outputPath)}</style>
9288
</span>),
9389
css: {
9490
toString: () =>
9591
// lazy-loaded in case not used
9692
(DEV
9793
? api.styles.toString()
98-
: `<span id='__styles__'>
99-
<style>${stylesAsString(stylesheets, outputPath)}</style>
100-
</span>`)
94+
: `<style>${stylesAsString(stylesheets, outputPath)}</style>`)
10195
},
10296

10397
// 4) names of files without publicPath or outputPath prefixed:

0 commit comments

Comments
 (0)