fix(builder): add OXC semantic to deconflic JS modules using the same global variables/functions
- this solve issues like: Uncaught SyntaxError: Identifier 'GROUP_BY_DEFS' has already been declared (at app.XXXX.js)
- add a protection on build: test to reload bundled app, on failure exit immediately (prevent the build or a broken bundle)
- add final check during CI: node --check on the bundle to brevent going to production too if any failure
example of a bundle:
```
warning: oxicloud@0.6.0: bundle: 50 files in dependency order:
warning: oxicloud@0.6.0: bundle: deconflicting 2 name(s): GROUP_BY_DEFS, LOAD_MORE_ID
warning: oxicloud@0.6.0: bundle: [29] GROUP_BY_DEFS -> GROUP_BY_DEFS_29 (favoritesView.js)
warning: oxicloud@0.6.0: bundle: [29] LOAD_MORE_ID -> LOAD_MORE_ID_29 (favoritesView.js)
warning: oxicloud@0.6.0: bundle: [31] GROUP_BY_DEFS -> GROUP_BY_DEFS_31 (recentView.js)
warning: oxicloud@0.6.0: bundle: [31] LOAD_MORE_ID -> LOAD_MORE_ID_31 (recentView.js)
warning: oxicloud@0.6.0: bundle: [34] GROUP_BY_DEFS -> GROUP_BY_DEFS_34 (sharedWithMeView.js)
warning: oxicloud@0.6.0: bundle: [34] LOAD_MORE_ID -> LOAD_MORE_ID_34 (sharedWithMeView.js)
warning: oxicloud@0.6.0: bundle: [44] GROUP_BY_DEFS -> GROUP_BY_DEFS_44 (filesView.js)
warning: oxicloud@0.6.0: bundle: [44] LOAD_MORE_ID -> LOAD_MORE_ID_44 (filesView.js)
```
This commit is contained in:
@@ -154,6 +154,13 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo build --release
|
||||
# build.rs runs the deconflict pass and js_bundle_validate() — any
|
||||
# duplicate declaration or parse error in the JS bundle fails here.
|
||||
- name: Validate JS bundle (node --check)
|
||||
# belt-and-suspenders: node --check parses the bundle without executing it.
|
||||
# Catches SyntaxErrors that OXC's parse check inside build.rs would also
|
||||
# catch, but gives a human-readable error line in the CI log.
|
||||
run: node --check static-dist/js/app.*.js
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: oxicloud-release
|
||||
|
||||
Reference in New Issue
Block a user