@xh/hoist-dev-utils 6.0.0 → 6.1.1

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/README.md CHANGED
@@ -14,9 +14,9 @@ including Webpack Dev Server, Babel, and other essential loaders.
14
14
 
15
15
  In most cases this package could be the _only_ dev dependency required by Hoist React apps, although
16
16
  apps might wish to configure additional tooling such as stylelint (for linting SASS files) or
17
- lint-staged (for running linters as a pre-commit git hook). See the
17
+ lint-staged and husky (for running linters as a pre-commit git hook). See the
18
18
  [Toolbox package.json](https://github.com/xh/toolbox/blob/develop/client-app/package.json) for
19
- examples of both of these libraries in action.
19
+ examples of these libraries in action.
20
20
 
21
21
  ### Webpack configuration
22
22
 
@@ -56,7 +56,6 @@ versioned 1.2.3 release).
56
56
  See the [Hoist React docs](https://github.com/xh/hoist-react/blob/develop/docs/build-and-deploy.md)
57
57
  for step-by-step details on the build process.
58
58
 
59
-
60
59
  ### Favicons
61
60
 
62
61
  To include a favicon with your app, provide the `favicon` option to `configureWebpack()`. This can be either
@@ -71,27 +70,32 @@ return configureWebpack({
71
70
  ```
72
71
 
73
72
  If your app is intended to be used on mobile devices, you may want to also include a wider variety of favicons.
74
- The following files will be automatically bundled in your app's manifest.json if they are found your `/public` folder:
73
+ The following files will be automatically bundled in your app's manifest.json if they are found in your project's
74
+ `/client-app/public` folder:
75
75
 
76
76
  + `favicon-192.png` (192px x 192px)
77
77
  + `favicon-512.png` (512px x 512px)
78
78
  + `apple-touch-icon.png` (180px x 180px)
79
79
 
80
80
  You can use the `svg-favicon.sh` script to automatically create these favicons from a square SVG. Note that this script
81
- requires inkscape to be installed. Download the latest version from [https://inkscape.org/](https://inkscape.org/)
81
+ requires inkscape to be installed. Download the latest version from [https://inkscape.org/](https://inkscape.org/) or
82
+ install on Mac via Homebrew with `brew install inkscape`.
82
83
 
83
- Inkscape includes a command-line interface which is leveraged by the script. In order for the script to be able to use it,
84
- you must first symlink Inkscape to `/usr/local/bin`:
84
+ Inkscape includes a command-line interface which is leveraged by the script. In order for the script to be able to use
85
+ it, you must first symlink Inkscape to `/usr/local/bin`. (Note this step is _not_ required if you have installed via
86
+ Homebrew.)
85
87
 
86
88
  ```shell
87
89
  ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape \
88
90
  /usr/local/bin/inkscape
89
91
  ```
90
92
 
91
- Then run the script, passing a path to the SVG file as the argument:
93
+ Then run the script, passing a path to the SVG file as the argument. The command below assumes that you have
94
+ `hoist-dev-utils` checked out as a sibling of your top-level project directory, and that you are running the command
95
+ from within `$projectDir/client-app/public`:
92
96
 
93
97
  ```shell
94
- sh svg-favicon.sh ./favicon.svg
98
+ ../../../hoist-dev-utils/svg-favicon.sh favicon.svg
95
99
  ```
96
100
 
97
101
  ### ESLint Configuration
@@ -29,7 +29,7 @@ const _ = require('lodash'),
29
29
  // this script locally to debug via `yarn link`.
30
30
  let hoistReactPkg, reactPkg;
31
31
  try {hoistReactPkg = require('@xh/hoist/package')} catch (e) {hoistReactPkg = {version: 'NOT_FOUND'}}
32
- try {reactPkg = require('react/package')} catch (e) {reactPkg = {version: 'NOT_FOUND'}}
32
+ try {reactPkg = require('react')} catch (e) {reactPkg = {version: 'NOT_FOUND'}}
33
33
 
34
34
  /**
35
35
  * Consolidated Webpack configuration for both dev-time and production builds of Hoist React web
@@ -301,10 +301,10 @@ async function configureWebpack(env) {
301
301
  const appDirPath = path.resolve(srcPath, 'apps'),
302
302
  apps = fs
303
303
  .readdirSync(appDirPath)
304
- .filter(f => f.endsWith('.js'))
304
+ .filter(f => f.endsWith('.js') || f.endsWith('.ts'))
305
305
  .map(f => {
306
306
  return {
307
- name: f.replace('.js', ''),
307
+ name: f.replace('.js', '').replace('.ts', ''),
308
308
  path: path.resolve(appDirPath, f)
309
309
  };
310
310
  }),
@@ -374,7 +374,7 @@ async function configureWebpack(env) {
374
374
  // Add JSX to support imports from .jsx source w/o needing to add the extension.
375
375
  // Include "*" to continue supporting other imports that *do* specify an extension
376
376
  // within the import statement (i.e. `import './foo.png'`). Yes, it's confusing.
377
- extensions: ['*', '.js', '.jsx', '.json']
377
+ extensions: ['*', '.js', '.ts', '.jsx', '.tsx', '.json']
378
378
  },
379
379
 
380
380
  // Ensure Webpack can find loaders installed both within the top-level node_modules dir for
@@ -424,15 +424,16 @@ async function configureWebpack(env) {
424
424
  },
425
425
 
426
426
  //------------------------
427
- // JS processing
427
+ // JS/TS processing
428
428
  // Transpile via Babel, with presets/plugins to support Hoist's use of modern / staged JS features.
429
429
  //------------------------
430
430
  {
431
- test: /\.(jsx?)$/,
431
+ test: /\.(jsx?)$|\.(tsx?)$/,
432
432
  use: {
433
433
  loader: 'babel-loader',
434
434
  options: {
435
435
  presets: [
436
+ '@babel/preset-typescript',
436
437
  '@babel/preset-react',
437
438
  [
438
439
  '@babel/preset-env',
@@ -456,16 +457,23 @@ async function configureWebpack(env) {
456
457
  ]
457
458
  ],
458
459
  plugins: [
460
+ // Support Typescript via Babel. `isTSX` option allows use of JSX inline with
461
+ // .js files for older JS apps. Typescript apps must use the .tsx extension for
462
+ // any files containing JSX syntax.
463
+ ['@babel/plugin-transform-typescript', {allowDeclareFields: true, isTSX: true}],
464
+
459
465
  // Support our current decorator syntax, for MobX and Hoist decorators.
460
466
  // See notes @ https://babeljs.io/docs/en/babel-plugin-proposal-decorators#legacy
461
- ['@babel/plugin-proposal-decorators', {legacy: true}],
467
+ // and https://mobx.js.org/enabling-decorators.html#babel-7
468
+ ['@babel/plugin-proposal-decorators', {version: 'legacy'}],
469
+
470
+ // Support class-level fields.
471
+ // Must come after decorators plugin as per Babel docs linked above.
472
+ ['@babel/plugin-proposal-class-properties'],
462
473
 
463
- // Support classes level fields - must come after decorators plugin and be loose.
464
- ['@babel/plugin-proposal-class-properties', {loose: true}],
465
- // Must also configure private-* plugins below to config the "loose" setting
466
- // to match plugin-proposal-class-properties.
467
- ['@babel/plugin-proposal-private-methods', {loose: true}],
468
- ['@babel/plugin-proposal-private-property-in-object', {loose: true}],
474
+ // Support private methods + properties.
475
+ ['@babel/plugin-proposal-private-methods'],
476
+ ['@babel/plugin-proposal-private-property-in-object'],
469
477
 
470
478
  // Support `let x = foo?.bar`.
471
479
  ['@babel/plugin-proposal-optional-chaining'],
@@ -702,7 +710,6 @@ async function configureWebpack(env) {
702
710
  };
703
711
  }
704
712
 
705
-
706
713
  //------------------------
707
714
  // Implementation
708
715
  //------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist-dev-utils",
3
- "version": "6.0.0",
3
+ "version": "6.1.1",
4
4
  "description": "Utilities for configuring builds of Hoist-React client applications.",
5
5
  "repository": "github:xh/hoist-dev-utils",
6
6
  "homepage": "https://github.com/xh/hoist-dev-utils",
@@ -11,16 +11,17 @@
11
11
  "configureWebpack.js"
12
12
  ],
13
13
  "dependencies": {
14
- "@babel/core": "~7.18.9",
15
- "@babel/plugin-proposal-decorators": "~7.18.9",
16
- "@babel/preset-env": "~7.18.9",
17
- "@babel/preset-react": "~7.18.6",
14
+ "@babel/core": "^7.20",
15
+ "@babel/plugin-proposal-decorators": "^7.20",
16
+ "@babel/preset-env": "^7.20",
17
+ "@babel/preset-react": "^7.18",
18
+ "@babel/preset-typescript": "^7.18",
18
19
  "@cerner/duplicate-package-checker-webpack-plugin": "~2.3.0",
19
20
  "@types/lodash": "^4.0.0",
20
- "@types/react": "^17.0.0",
21
- "@xh/eslint-config": "~4.0.1",
22
- "autoprefixer": "~10.4.7",
23
- "babel-loader": "~8.2.5",
21
+ "@types/react": "^18.0.0",
22
+ "@xh/eslint-config": "^5.0.0",
23
+ "autoprefixer": "~10.4.13",
24
+ "babel-loader": "~9.1.0",
24
25
  "babel-plugin-transform-imports": "~2.0.0",
25
26
  "case-sensitive-paths-webpack-plugin": "~2.4.0",
26
27
  "changelog-parser": "~2.8.1",
@@ -31,21 +32,21 @@
31
32
  "html-webpack-plugin": "~5.5.0",
32
33
  "html-webpack-tags-plugin": "~3.0.2",
33
34
  "lodash": "~4.17.21",
34
- "mini-css-extract-plugin": "~2.6.1",
35
+ "mini-css-extract-plugin": "~2.7.0",
35
36
  "postcss": "~8.4.14",
36
37
  "postcss-flexbugs-fixes": "~5.0.2",
37
38
  "postcss-loader": "~7.0.1",
38
39
  "rimraf": "~3.0.2",
39
- "sass": "~1.53.0",
40
- "sass-loader": "~13.0.2",
40
+ "sass": "~1.56.1",
41
+ "sass-loader": "~13.2.0",
41
42
  "sass-material-colors": "~0.0.5",
42
43
  "style-loader": "~3.3.1",
43
44
  "terser-webpack-plugin": "~5.3.3",
44
45
  "url-loader": "~4.1.1",
45
- "webpack": "~5.73.0",
46
- "webpack-bundle-analyzer": "~4.5.0",
47
- "webpack-cli": "~4.10.0",
48
- "webpack-dev-server": "~4.9.3",
46
+ "webpack": "~5.75.0",
47
+ "webpack-bundle-analyzer": "~4.7.0",
48
+ "webpack-cli": "~5.0.0",
49
+ "webpack-dev-server": "~4.11.1",
49
50
  "webpackbar": "~5.0.2"
50
51
  }
51
52
  }