@abcnews/aunty 12.1.3 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcnews/aunty",
3
- "version": "12.1.3",
3
+ "version": "12.2.0",
4
4
  "description": "A toolkit for working with ABC News projects",
5
5
  "repository": "abcnews/aunty",
6
6
  "license": "MIT",
@@ -1,4 +1,5 @@
1
1
  // Native
2
+ const { existsSync } = require('fs');
2
3
  const { join } = require('path');
3
4
 
4
5
  // External
@@ -154,4 +155,8 @@ module.exports = command(
154
155
  }
155
156
  );
156
157
 
157
- const updateJsonFile = (path, source) => writeJsonFile.sync(path, combine(loadJsonFile.sync(path), source));
158
+ const updateJsonFile = (path, source) => {
159
+ if (existsSync(path)) {
160
+ writeJsonFile.sync(path, combine(loadJsonFile.sync(path), source));
161
+ }
162
+ };
@@ -1,23 +1,23 @@
1
1
  import acto from '@abcnews/alternating-case-to-object';
2
2
  import { <% if (isOdyssey) { %>whenOdysseyLoaded<% } else { %>whenDOMReady<% } %> } from '@abcnews/env-utils';
3
- import { getMountValue, selectMounts } from '@abcnews/mount-utils';<% if (isTS) { %>
4
- import type { Mount } from '@abcnews/mount-utils';<% } %>
3
+ import { getMountValue, selectMounts } from '@abcnews/mount-utils';
5
4
  import React from 'react';
6
- import { render } from 'react-dom';
5
+ import { createRoot<% if (isTS) { %>, Root<% } %> } from 'react-dom/client';
7
6
  import App from './components/App';<% if (isTS) { %>
8
7
  import type { AppProps } from './components/App';<% } %>
9
8
 
10
- let appMountEl<% if (isTS) { %>: Mount<% } %>;
9
+ let root<% if (isTS) { %>: Root<% } %>;
11
10
  let appProps<% if (isTS) { %>: AppProps<% } %>;
12
11
 
13
12
  function renderApp() {
14
- render(<App {...appProps} />, appMountEl);
13
+ root.render(<App {...appProps} />);
15
14
  }
16
15
 
17
16
  <% if (isOdyssey) { %>whenOdysseyLoaded<% } else { %>whenDOMReady<% } %>.then(() => {
18
- [appMountEl] = selectMounts('<%= projectNameFlat %>');
17
+ const [appMountEl] = selectMounts('<%= projectNameFlat %>');
19
18
 
20
19
  if (appMountEl) {
20
+ root = createRoot(appMountEl);
21
21
  appProps = acto(getMountValue(appMountEl))<% if (isTS) { %> as AppProps<% } %>;
22
22
  renderApp();
23
23
  }
@@ -29,7 +29,7 @@ if (module.hot) {
29
29
  renderApp();
30
30
  } catch (err) {
31
31
  import('./components/ErrorBox').then(({ default: ErrorBox }) => {
32
- render(<ErrorBox error={err} />, appMountEl);
32
+ root.render(<ErrorBox error={err} />);
33
33
  });
34
34
  }
35
35
  });