@s-ui/bundler 9.74.0 → 9.77.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/README.md CHANGED
@@ -102,6 +102,21 @@ $ sui-bundler dev -L ../frontend-ma--uilib-components/components
102
102
 
103
103
  And of course you can combine `link-all` and `link-package` flags
104
104
 
105
+ #### Packages with their own watcher (dev script)
106
+
107
+ When using `--link-package` or `--link-all`, packages that define a `dev` script in their `package.json` are **automatically excluded** from being linked by `sui-bundler`. These packages are expected to handle their own file watching and compilation via their `dev` script, so linking them would be redundant or could cause conflicts.
108
+
109
+ ```json
110
+ // package.json of the linked package
111
+ {
112
+ "scripts": {
113
+ "dev": "tsup --watch" // this package will NOT be linked by sui-bundler
114
+ }
115
+ }
116
+ ```
117
+
118
+ > **Note:** If the package is **not part of the monorepo** (i.e. it lives outside the project remember to use [`npm link`](https://docs.npmjs.com/cli/commands/npm-link) directly instead.
119
+
105
120
  ### Production
106
121
 
107
122
  ```
@@ -20,6 +20,10 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
20
20
  program
21
21
  .option('-C, --clean', 'Remove public folder before create a new one')
22
22
  .option('-S, --save-stats', 'Save stats.json in public folder')
23
+ .option(
24
+ '--stats-options [options]',
25
+ 'Stats options as JSON string (e.g., \'{"modules":true,"assets":true,"chunks":true}\')'
26
+ )
23
27
  .option(
24
28
  '-l, --link-package [package]',
25
29
  'Replace each occurrence of this package with an absolute path to this folder',
@@ -35,13 +39,14 @@ program
35
39
  console.log('')
36
40
  console.log(' $ sui-bundler build -S')
37
41
  console.log(' $ sui-bundler build -SC')
42
+ console.log(' $ sui-bundler build -S --stats-options \'{"modules":true,"assets":true}\'')
38
43
  console.log(' $ sui-bundler dev --link-package /my/domain/folder')
39
44
  console.log(' $ sui-bundler build --help')
40
45
  console.log('')
41
46
  })
42
47
  .parse(process.argv)
43
48
 
44
- const {clean = false, context, saveStats, linkPackage: packagesToLink = []} = program.opts()
49
+ const {clean = false, context, saveStats, statsOptions, linkPackage: packagesToLink = []} = program.opts()
45
50
 
46
51
  config.context = context || config.context
47
52
 
@@ -85,9 +90,21 @@ compiler.run(async (error, stats) => {
85
90
 
86
91
  console.log(`Webpack stats: ${stats}`)
87
92
 
88
- if (saveStats) {
93
+ if (saveStats && stats) {
89
94
  const filePath = `${process.cwd()}/public/stats.json`
90
- fs.writeFileSync(filePath, JSON.stringify(stats.toJson(), null, 2), {
95
+ let statsConfig
96
+
97
+ if (statsOptions) {
98
+ try {
99
+ statsConfig = JSON.parse(statsOptions)
100
+ } catch (err) {
101
+ log.error('Invalid JSON format for --stats-options')
102
+ return process.exit(1)
103
+ }
104
+ }
105
+
106
+ const statsData = statsConfig ? stats.toJson(statsConfig) : stats.toJson()
107
+ fs.writeFileSync(filePath, JSON.stringify(statsData, null, 2), {
91
108
  encoding: 'utf8'
92
109
  })
93
110
  }
@@ -10,8 +10,12 @@ const diccFromAbsolutePaths = (paths, init = {}) =>
10
10
  const packagePath = path.resolve(pkg)
11
11
  try {
12
12
  const pkg = require(path.join(packagePath, 'package.json'))
13
- acc[pkg.name] = path.join(packagePath, 'src')
14
- log.success(`✔ ${pkg.name} from path "${packagePath}"`)
13
+ if (pkg.scripts?.dev) {
14
+ log.info(`ℹ Package from path "${packagePath}" wouldn't be linked because it has its own watcher.`)
15
+ } else {
16
+ acc[pkg.name] = path.join(packagePath, 'src')
17
+ log.success(`✔ ${pkg.name} from path "${packagePath}"`)
18
+ }
15
19
  return acc
16
20
  } catch (e) {
17
21
  log.warn(`⚠ Package from path "${packagePath}" can't be linked.\n Path is wrong or package.json is missing.`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "9.74.0",
3
+ "version": "9.77.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"