@kaliber/build 0.0.125 → 0.0.128

Sign up to get free protection for your applications and to get access to all the features.
package/.eslintrc CHANGED
@@ -70,6 +70,7 @@
70
70
  "dot-location": ["warn", "property"],
71
71
  "eol-last": "warn",
72
72
  "eqeqeq": "warn",
73
+ "key-spacing": "warn",
73
74
  "keyword-spacing": "warn",
74
75
  "new-parens": "warn",
75
76
  "no-array-constructor": "warn",
@@ -1,4 +1,5 @@
1
1
  import ReactDom from 'react-dom'
2
+ import { safeJsonStringify } from '@kaliber/safe-json-stringify'
2
3
 
3
4
  const containerMarker = 'data-kaliber-component-container'
4
5
 
@@ -12,7 +13,9 @@ export function ComponentServerWrapper({ componentName, props, renderedComponent
12
13
 
13
14
  {/* Use render blocking script to remove the container and supply the correct comment nodes.
14
15
  This ensures the page is never rendered with the intermediate structure */}
15
- <script dangerouslySetInnerHTML={{ __html: restructureDomNodes(componentInfo) }} />
16
+ <script dangerouslySetInnerHTML={{
17
+ __html: restructureDomNodes(componentInfo).replace(/<\/?script>/gi, '')
18
+ }} />
16
19
  </>
17
20
  )
18
21
  }
@@ -81,10 +84,11 @@ function groupComponentsByName(allComponents) {
81
84
  }
82
85
 
83
86
  function restructureDomNodes(componentInfo) {
87
+ const safeComponentInfo = safeJsonStringify(componentInfo)
84
88
  return `|var d=document,s=d.currentScript,p=s.parentNode,c=s.previousSibling;
85
89
  |p.setAttribute('${containerMarker}',''); // set marker on container so we can retrieve nodes that contain components
86
90
  |p.replaceChild(d.createComment('start'),c); // replace kaliber-component-container element with a 'start' comment
87
- |p.insertBefore(d.createComment(JSON.stringify(${componentInfo})),s); // create a comment containing the component info
91
+ |p.insertBefore(d.createComment(${safeComponentInfo}),s); // create a comment containing the component info
88
92
  |Array.from(c.childNodes).forEach(x=>{p.insertBefore(x,s)}); // insert all children from the kaliber-component-container element
89
93
  |p.replaceChild(d.createComment('end'),s); // create an 'end' comment
90
94
  |`.replace(/^\s*\|/gm, '').replace(/\s*\/\/[^;]*?$/gm, '').replace(/\n/g, '')
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.125",
2
+ "version": "0.0.128",
3
3
  "name": "@kaliber/build",
4
4
  "description": "Zero configuration, opinionated webpack / react build setup",
5
5
  "scripts": {
@@ -29,6 +29,7 @@
29
29
  "@babel/runtime": "^7.11.2",
30
30
  "@kaliber/config": "^0.0.8",
31
31
  "@kaliber/eslint-plugin": "*",
32
+ "@kaliber/safe-json-stringify": "^1.1.0",
32
33
  "ansi-regex": "^5.0.0",
33
34
  "babel-loader": "^8.0.6",
34
35
  "cache-loader": "^4.1.0",
@@ -93,8 +93,9 @@ module.exports = function templatePlugin(renderers) {
93
93
  */
94
94
  compilation.hooks.chunkAsset.tap(p, (chunk, file) => {
95
95
  if (!chunk.entryModule) return
96
+ const rootModule = chunk.entryModule.rootModule || chunk.entryModule
96
97
  const { module } =
97
- chunk.entryModule.dependencies.find(x =>
98
+ rootModule.dependencies.find(x =>
98
99
  x.module && x.module.request.endsWith('?template-source')
99
100
  ) || {}
100
101
  if (!module) return