@kaliber/build 0.0.126 → 0.0.129

Sign up to get free protection for your applications and to get access to all the features.
package/lib/polyfill.js CHANGED
@@ -4,5 +4,5 @@ export default function polyfill(features = []) {
4
4
  const src = isProduction
5
5
  ? `https://cdn.polyfill.io/v3/polyfill.min.js?rum=0&unknown=polyfill&flags=gated&features=${features.join(',')}`
6
6
  : `https://cdn.polyfill.io/v3/polyfill.js?rum=0&unknown=polyfill&flags=gated&features=${features.join(',')}`
7
- return <script defer src={src} crossOrigin="anonymous" />
7
+ return <script src={src} crossOrigin="anonymous" />
8
8
  }
@@ -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.126",
2
+ "version": "0.0.129",
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",