islandjs-rails 0.7.0 ā 1.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +67 -2
- data/LICENSE.md +1 -1
- data/README.md +60 -52
- data/lib/islandjs_rails/cli.rb +2 -2
- data/lib/islandjs_rails/configuration.rb +2 -3
- data/lib/islandjs_rails/core.rb +15 -69
- data/lib/islandjs_rails/core_methods.rb +61 -65
- data/lib/islandjs_rails/rails_helpers.rb +38 -16
- data/lib/islandjs_rails/railtie.rb +6 -6
- data/lib/islandjs_rails/tasks.rb +2 -2
- data/lib/islandjs_rails/vendor_manager.rb +6 -3
- data/lib/islandjs_rails/version.rb +1 -1
- data/lib/islandjs_rails/vite_installer.rb +286 -0
- data/lib/islandjs_rails/vite_integration.rb +148 -0
- data/lib/islandjs_rails.rb +1 -0
- data/lib/templates/app/javascript/entrypoints/islands.js +20 -0
- data/lib/templates/app/views/islandjs_demo/index.html.erb +2 -2
- data/lib/templates/package.json +4 -11
- data/lib/templates/script/build-vite-atomic.js +89 -0
- data/lib/templates/vite.config.islands.ts +67 -0
- metadata +9 -8
- data/islandjs-rails.gemspec +0 -55
- data/lib/templates/app/javascript/islands/index.js +0 -10
- data/lib/templates/webpack.config.js +0 -85
- data/package.json +0 -12
- data/yarn.lock +0 -1890
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 785899eb40416f27f56fa482ab4c3241a2cd1637c81c75c025f3d03d39bb2c23
|
|
4
|
+
data.tar.gz: 86854c83387842f66a1899795bbfe3be4061190e7814fc4502aaa0727d011f6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f8d054fb90b600243af937d36d338b21c5b1c8b658bd775452aeced0db465c02a95a83520578d623705f6e729a9a0b5dd9ec78fbd23c164091f14b7a15591a1
|
|
7
|
+
data.tar.gz: 3b6e35821a2958438332f84ee34521659fbcaf259cb5753df046822b112af26186842258579f7d07d935935556b770dc1e4609311543195d3add897381c3940d
|
data/CHANGELOG.md
CHANGED
|
@@ -5,11 +5,76 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.0] - 2025-11-05
|
|
9
|
+
|
|
10
|
+
### š Major Release: Webpack ā Vite Migration
|
|
11
|
+
|
|
12
|
+
This release replaces webpack with Vite for a dramatically faster, more modern build system.
|
|
13
|
+
|
|
14
|
+
### ā ļø BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
**Build System**:
|
|
17
|
+
- Replaced webpack with Vite as the build tool
|
|
18
|
+
- Config file changed: `webpack.config.js` ā `vite.config.islands.ts`
|
|
19
|
+
- Build command changed: `yarn build` ā `yarn build:islands`
|
|
20
|
+
- Watch command changed: `yarn watch` ā `yarn watch:islands`
|
|
21
|
+
- Manifest location changed: `public/islands_manifest.json` ā `public/islands/.vite/manifest.json`
|
|
22
|
+
|
|
23
|
+
**Dependencies**:
|
|
24
|
+
- Removed: `webpack`, `webpack-cli`, `webpack-manifest-plugin`
|
|
25
|
+
- Added: `vite`, `@vitejs/plugin-react`
|
|
26
|
+
- Note: Uses Vite directly via npm/yarn, not the `vite_rails` Ruby gem
|
|
27
|
+
|
|
28
|
+
**Files**:
|
|
29
|
+
- `app/javascript/islands/index.js` is no longer created (Vite uses entrypoints directly)
|
|
30
|
+
- New file: `vite.config.islands.ts` for Islands-specific Vite configuration
|
|
31
|
+
|
|
32
|
+
### ā
What Stays the Same
|
|
33
|
+
|
|
34
|
+
**No code changes needed!** All runtime APIs remain identical:
|
|
35
|
+
- All Rails helpers work the same (`react_component`, `island_partials`, etc.)
|
|
36
|
+
- Island components don't need any changes
|
|
37
|
+
- ERB templates don't need any changes
|
|
38
|
+
- UMD vendor system works identically
|
|
39
|
+
- All `rails islandjs:*` commands work the same way
|
|
40
|
+
|
|
41
|
+
### š Benefits
|
|
42
|
+
|
|
43
|
+
- ā” **2-10x faster builds** compared to webpack
|
|
44
|
+
- š„ **Instant Hot Module Replacement (HMR)** during development
|
|
45
|
+
- š¦ **Smaller bundle sizes** with superior tree-shaking
|
|
46
|
+
- šÆ **Simpler configuration** - no complex webpack setup needed
|
|
47
|
+
- š **Modern tooling** - built for ES modules and modern JavaScript
|
|
48
|
+
- š§ **Lightweight integration** - uses Vite directly without additional Ruby dependencies
|
|
49
|
+
|
|
50
|
+
### š Upgrade Guide
|
|
51
|
+
|
|
52
|
+
See [UPGRADING.md](UPGRADING.md) for detailed migration instructions. Summary:
|
|
53
|
+
|
|
54
|
+
1. Update gem: `bundle update islandjs-rails`
|
|
55
|
+
2. Remove webpack files: `rm webpack.config.js`
|
|
56
|
+
3. Reinitialize: `rails islandjs:init`
|
|
57
|
+
4. Rebuild: `yarn build:islands`
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
- Updated all documentation to reference Vite instead of webpack
|
|
62
|
+
- CLI and Rake task descriptions now mention "Vite externals" instead of "webpack externals"
|
|
63
|
+
- Build output messages updated for Vite workflow
|
|
64
|
+
- Error messages and hints updated to reference Vite commands
|
|
65
|
+
|
|
66
|
+
### Removed
|
|
67
|
+
|
|
68
|
+
- Webpack configuration template
|
|
69
|
+
- Webpack-related dependencies from package.json template
|
|
70
|
+
- `ESSENTIAL_DEPENDENCIES` constant (replaced with inline Vite deps)
|
|
71
|
+
- References to webpack in README, gemspec, and all documentation
|
|
72
|
+
|
|
8
73
|
## [0.7.0] - 2025-10-27
|
|
9
74
|
|
|
10
75
|
### Added
|
|
11
|
-
- **CleanIslandsPlugin**:
|
|
12
|
-
- Simplified build scripts by removing manual
|
|
76
|
+
- **CleanIslandsPlugin**: Build plugin that automatically removes old island bundle files from the public directory after new builds, preventing stale file accumulation
|
|
77
|
+
- Simplified build scripts by removing manual cleanup commands
|
|
13
78
|
|
|
14
79
|
## [0.6.0] - 2025-10-24
|
|
15
80
|
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
|
@@ -30,14 +30,17 @@ rails islandjs:init
|
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### Install React
|
|
33
|
+
|
|
34
|
+
> **Note:** Currently limited to React 19.1.0 until [umd-react](https://github.com/lofcz/umd-react) workflow is fixed (PR pending) to publish newer versions to unpkg.com properly.
|
|
35
|
+
|
|
33
36
|
```bash
|
|
34
|
-
rails "islandjs:install[react,19.
|
|
35
|
-
rails "islandjs:install[react-dom,19.
|
|
37
|
+
rails "islandjs:install[react,19.1.0]"
|
|
38
|
+
rails "islandjs:install[react-dom,19.1.0]"
|
|
36
39
|
```
|
|
37
40
|
|
|
38
41
|
### Run Yarn In Development
|
|
39
42
|
```bash
|
|
40
|
-
yarn watch
|
|
43
|
+
yarn watch:islands
|
|
41
44
|
```
|
|
42
45
|
|
|
43
46
|
### Render React Components
|
|
@@ -53,7 +56,7 @@ yarn watch
|
|
|
53
56
|
|
|
54
57
|
### Build For Production
|
|
55
58
|
```bash
|
|
56
|
-
yarn build
|
|
59
|
+
yarn build:islands
|
|
57
60
|
```
|
|
58
61
|
|
|
59
62
|
> š” **Turbo Cache Compatible**: React components automatically persist state across Turbo navigation! See [Turbo Cache Integration](#turbo-cache-integration) for details.
|
|
@@ -114,15 +117,15 @@ Modern Rails developers face a painful choice:
|
|
|
114
117
|
|
|
115
118
|
### The IslandJS Rails Solution
|
|
116
119
|
```bash
|
|
117
|
-
# Instead of complex
|
|
118
|
-
rails "islandjs:install[react,19.
|
|
120
|
+
# Instead of complex build configuration:
|
|
121
|
+
rails "islandjs:install[react,19.1.0]"
|
|
119
122
|
rails "islandjs:install[react-beautiful-dnd]"
|
|
120
123
|
rails "islandjs:install[quill]"
|
|
121
124
|
rails "islandjs:install[recharts]"
|
|
122
125
|
rails "islandjs:install[lodash]"
|
|
123
126
|
```
|
|
124
127
|
|
|
125
|
-
**Result**: Zero
|
|
128
|
+
**Result**: Zero build configuration, instant prod builds, access to hundreds of UMD packages.
|
|
126
129
|
|
|
127
130
|
### Access UMD installed JS packages via the window from within React components:
|
|
128
131
|
```bash
|
|
@@ -154,7 +157,7 @@ If you absolutely need a package that doesn't ship UMD builds, you have a few op
|
|
|
154
157
|
- **Package.json Integration** - (npm + yarn)
|
|
155
158
|
- **CDN Downloads** - Fetches UMD builds from unpkg.com and jsdelivr.net
|
|
156
159
|
- **Rails Integration** - Serves auto-generated vendor UMD files for seamless integration
|
|
157
|
-
- **
|
|
160
|
+
- **Vite Externals** - Updates vite.config.islands.ts to prevent duplicate bundling while allowing development in jsx or other formats
|
|
158
161
|
- **Placeholder Support** - Eliminate layout shift with automatic placeholder management ā” *New in v0.2.0*
|
|
159
162
|
- **Flexible Architecture** - Compose and namespace libraries as needed
|
|
160
163
|
|
|
@@ -170,12 +173,12 @@ rails islandjs:init
|
|
|
170
173
|
|
|
171
174
|
# Install packages (adds to package.json + saves to vendor directory)
|
|
172
175
|
rails "islandjs:install[react]"
|
|
173
|
-
rails "islandjs:install[react,19.
|
|
176
|
+
rails "islandjs:install[react,19.1.0]" # With specific version
|
|
174
177
|
rails "islandjs:install[lodash]"
|
|
175
178
|
|
|
176
179
|
# Update packages (updates package.json + refreshes vendor files)
|
|
177
180
|
rails "islandjs:update[react]"
|
|
178
|
-
rails "islandjs:update[react,19.
|
|
181
|
+
rails "islandjs:update[react,19.1.0]" # To specific version
|
|
179
182
|
|
|
180
183
|
# Remove packages (removes from package.json + deletes vendor files)
|
|
181
184
|
rails "islandjs:remove[react]"
|
|
@@ -216,27 +219,24 @@ For development and building your JavaScript:
|
|
|
216
219
|
|
|
217
220
|
```bash
|
|
218
221
|
# Development - watch for changes and rebuild automatically
|
|
219
|
-
yarn watch
|
|
220
|
-
# Or with npm: npm run watch
|
|
222
|
+
yarn watch:islands
|
|
221
223
|
|
|
222
224
|
# Production - build optimized bundle for deployment
|
|
223
|
-
yarn build
|
|
224
|
-
# Or with npm: npm run build
|
|
225
|
+
yarn build:islands
|
|
225
226
|
|
|
226
227
|
# Install dependencies (after adding packages via islandjs:install)
|
|
227
228
|
yarn install
|
|
228
|
-
# Or with npm: npm install
|
|
229
229
|
```
|
|
230
230
|
|
|
231
231
|
**Development Workflow:**
|
|
232
|
-
1. Run `yarn watch`
|
|
232
|
+
1. Run `yarn watch:islands` in one terminal
|
|
233
233
|
2. Edit your components in `app/javascript/islands/components/`
|
|
234
|
-
3. Changes are automatically compiled
|
|
234
|
+
3. Changes are automatically compiled and fingerprinted
|
|
235
235
|
|
|
236
236
|
**Production Deployment:**
|
|
237
|
-
1. Run `yarn build`
|
|
238
|
-
2. Commit the built assets: `git add public/
|
|
239
|
-
3. Deploy
|
|
237
|
+
1. Run `yarn build:islands` to create optimized bundle with content hashing
|
|
238
|
+
2. Commit the built assets: `git add public/islands/`
|
|
239
|
+
3. Deploy - Vite's content hashing ensures automatic cache busting
|
|
240
240
|
|
|
241
241
|
## š¦ Working with Scoped Packages
|
|
242
242
|
|
|
@@ -313,21 +313,24 @@ function SolanaComponent() {
|
|
|
313
313
|
export default SolanaComponent;
|
|
314
314
|
```
|
|
315
315
|
|
|
316
|
-
###
|
|
316
|
+
### Vite Externals
|
|
317
317
|
|
|
318
|
-
IslandJS Rails automatically configures
|
|
318
|
+
IslandJS Rails automatically configures Vite externals for scoped packages:
|
|
319
319
|
|
|
320
|
-
```
|
|
321
|
-
//
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
320
|
+
```typescript
|
|
321
|
+
// vite.config.islands.ts (auto-generated)
|
|
322
|
+
export default defineConfig({
|
|
323
|
+
build: {
|
|
324
|
+
rollupOptions: {
|
|
325
|
+
external: ['@solana/web3.js'],
|
|
326
|
+
output: {
|
|
327
|
+
globals: {
|
|
328
|
+
'@solana/web3.js': 'solanaWeb3'
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
});
|
|
331
334
|
```
|
|
332
335
|
|
|
333
336
|
### Troubleshooting Scoped Packages
|
|
@@ -354,7 +357,7 @@ rails "islandjs:install[@solana/web3]" # ā Wrong
|
|
|
354
357
|
| Command | What it does | Example |
|
|
355
358
|
|---------|--------------|---------|
|
|
356
359
|
| `install` | Adds package via yarn + downloads UMD + saves to vendor | `rails islandjs:install[react]` |
|
|
357
|
-
| `update` | Updates package version + refreshes UMD | `rails islandjs:update[react,19.
|
|
360
|
+
| `update` | Updates package version + refreshes UMD | `rails islandjs:update[react,19.1.0]` |
|
|
358
361
|
| `remove` | Removes package via yarn + deletes vendor files | `rails islandjs:remove[react]` |
|
|
359
362
|
| `clean` | Removes ALL vendor files (destructive!) | `rails islandjs:clean` |
|
|
360
363
|
|
|
@@ -366,8 +369,7 @@ IslandjsRails.configure do |config|
|
|
|
366
369
|
# Directory for ERB partials (default: app/views/shared/islands)
|
|
367
370
|
config.partials_dir = Rails.root.join('app/views/shared/islands')
|
|
368
371
|
|
|
369
|
-
#
|
|
370
|
-
config.webpack_config_path = Rails.root.join('webpack.config.js')
|
|
372
|
+
# Vite Islands configuration is at vite.config.islands.ts (auto-managed)
|
|
371
373
|
|
|
372
374
|
# Vendor file delivery mode (default: :external_split)
|
|
373
375
|
config.vendor_script_mode = :external_split # One file per library
|
|
@@ -389,7 +391,7 @@ end
|
|
|
389
391
|
### Helpers
|
|
390
392
|
|
|
391
393
|
#### `islands`
|
|
392
|
-
Single helper that includes all UMD vendor scripts and your
|
|
394
|
+
Single helper that includes all UMD vendor scripts and your Vite bundle.
|
|
393
395
|
|
|
394
396
|
```erb
|
|
395
397
|
<%= islands %>
|
|
@@ -397,7 +399,7 @@ Single helper that includes all UMD vendor scripts and your webpack bundle.
|
|
|
397
399
|
|
|
398
400
|
This automatically loads:
|
|
399
401
|
- All UMD libraries from vendor files (either split or combined mode)
|
|
400
|
-
- Your
|
|
402
|
+
- Your Vite bundle
|
|
401
403
|
- Debug information in development
|
|
402
404
|
|
|
403
405
|
#### `react_component(name, props, options, &block)`
|
|
@@ -606,18 +608,25 @@ window.islandjsRails = {
|
|
|
606
608
|
const { React, UI, Utils } = window.islandjsRails;
|
|
607
609
|
```
|
|
608
610
|
|
|
609
|
-
###
|
|
611
|
+
### Vite Integration
|
|
610
612
|
|
|
611
|
-
IslandJS Rails automatically updates your
|
|
613
|
+
IslandJS Rails automatically updates your Vite externals:
|
|
612
614
|
|
|
613
|
-
```
|
|
614
|
-
//
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
615
|
+
```typescript
|
|
616
|
+
// vite.config.islands.ts (auto-generated)
|
|
617
|
+
export default defineConfig({
|
|
618
|
+
build: {
|
|
619
|
+
rollupOptions: {
|
|
620
|
+
external: ['react', 'react-dom'],
|
|
621
|
+
output: {
|
|
622
|
+
globals: {
|
|
623
|
+
'react': 'React',
|
|
624
|
+
'react-dom': 'ReactDOM'
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
619
628
|
}
|
|
620
|
-
};
|
|
629
|
+
});
|
|
621
630
|
```
|
|
622
631
|
|
|
623
632
|
### Configuration Options
|
|
@@ -627,8 +636,7 @@ IslandjsRails.configure do |config|
|
|
|
627
636
|
# Directory for ERB partials (default: app/views/shared/islands)
|
|
628
637
|
config.partials_dir = Rails.root.join('app/views/shared/islands')
|
|
629
638
|
|
|
630
|
-
#
|
|
631
|
-
config.webpack_config_path = Rails.root.join('webpack.config.js')
|
|
639
|
+
# Vite Islands config is at vite.config.islands.ts (auto-managed)
|
|
632
640
|
|
|
633
641
|
# Path to package.json (default: package.json)
|
|
634
642
|
config.package_json_path = Rails.root.join('package.json')
|
|
@@ -665,11 +673,11 @@ end
|
|
|
665
673
|
**Global name conflicts:**
|
|
666
674
|
IslandJS Rails includes built-in mappings for common libraries. For packages with unusual global names, check the library's documentation or browser console to find the correct global variable name.
|
|
667
675
|
|
|
668
|
-
**
|
|
676
|
+
**Vite externals not updating:**
|
|
669
677
|
```bash
|
|
670
678
|
# Sync to update externals
|
|
671
679
|
rails islandjs:sync
|
|
672
|
-
|
|
680
|
+
```
|
|
673
681
|
# Or clean and reinstall
|
|
674
682
|
rails islandjs:clean
|
|
675
683
|
rails islandjs:install[react]
|
|
@@ -734,6 +742,6 @@ Planned features for future releases:
|
|
|
734
742
|
- **Fast Deploys**: CDN libraries cache globally
|
|
735
743
|
|
|
736
744
|
### šÆ **Developer Experience**
|
|
737
|
-
- **Zero
|
|
745
|
+
- **Zero Build Expertise**: Rails developers stay in Rails
|
|
738
746
|
- **Turbo Compatible**: Seamless navigation and caching
|
|
739
747
|
- **Progressive Enhancement**: Start with Hotwire, add React islands
|
data/lib/islandjs_rails/cli.rb
CHANGED
|
@@ -32,7 +32,7 @@ module IslandjsRails
|
|
|
32
32
|
IslandjsRails.status!
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
desc "clean", "Clean all island partials and reset
|
|
35
|
+
desc "clean", "Clean all island partials and reset Vite externals"
|
|
36
36
|
def clean
|
|
37
37
|
IslandjsRails.clean!
|
|
38
38
|
end
|
|
@@ -44,7 +44,7 @@ module IslandjsRails
|
|
|
44
44
|
puts "=" * 40
|
|
45
45
|
puts "Package.json path: #{config.package_json_path}"
|
|
46
46
|
puts "Partials directory: #{config.partials_dir}"
|
|
47
|
-
puts "
|
|
47
|
+
puts "Vite Islands config: vite.config.islands.ts"
|
|
48
48
|
puts "Supported CDNs: #{config.supported_cdns.join(', ')}"
|
|
49
49
|
puts "Built-in global name overrides: #{IslandjsRails::BUILT_IN_GLOBAL_NAME_OVERRIDES.size} available"
|
|
50
50
|
end
|
|
@@ -2,16 +2,15 @@ require 'pathname'
|
|
|
2
2
|
|
|
3
3
|
module IslandjsRails
|
|
4
4
|
class Configuration
|
|
5
|
-
attr_accessor :package_json_path, :partials_dir, :
|
|
5
|
+
attr_accessor :package_json_path, :partials_dir, :supported_cdns,
|
|
6
6
|
:vendor_script_mode, :vendor_order, :vendor_dir, :combined_basename
|
|
7
7
|
|
|
8
8
|
def initialize
|
|
9
9
|
@package_json_path = Rails.root.join('package.json')
|
|
10
10
|
@partials_dir = Rails.root.join('app', 'views', 'shared', 'islands')
|
|
11
|
-
@webpack_config_path = Rails.root.join('webpack.config.js')
|
|
12
11
|
@vendor_script_mode = :external_split # :external_split or :external_combined
|
|
13
12
|
@vendor_order = %w[react react-dom] # combine order for :external_combined
|
|
14
|
-
@vendor_dir = Rails.root.join('public', '
|
|
13
|
+
@vendor_dir = Rails.root.join('public', 'vendor', 'islands')
|
|
15
14
|
@combined_basename = 'islands-vendor'
|
|
16
15
|
@supported_cdns = [
|
|
17
16
|
'https://unpkg.com',
|
data/lib/islandjs_rails/core.rb
CHANGED
|
@@ -12,67 +12,14 @@ module IslandjsRails
|
|
|
12
12
|
@configuration = IslandjsRails.configuration
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
#
|
|
16
|
-
ESSENTIAL_DEPENDENCIES = [
|
|
17
|
-
'webpack@^5.88.2',
|
|
18
|
-
'webpack-cli@^5.1.4',
|
|
19
|
-
'terser-webpack-plugin@^5.3.14',
|
|
20
|
-
'webpack-manifest-plugin@^5.0.1',
|
|
21
|
-
'babel-loader@^9.1.3',
|
|
22
|
-
'@babel/core@^7.23.0',
|
|
23
|
-
'@babel/preset-env@^7.23.0',
|
|
24
|
-
'@babel/preset-react@^7.23.0'
|
|
25
|
-
].freeze
|
|
15
|
+
# No longer needed - Vite handles bundling
|
|
26
16
|
|
|
27
17
|
# Initialize IslandJS in a Rails project
|
|
28
18
|
def init!
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# Step 2: Ensure package.json exists
|
|
35
|
-
ensure_package_json!
|
|
36
|
-
|
|
37
|
-
# Step 3: Install essential webpack dependencies
|
|
38
|
-
install_essential_dependencies!
|
|
39
|
-
|
|
40
|
-
# Step 4: Create scaffolded structure
|
|
41
|
-
create_scaffolded_structure!
|
|
42
|
-
|
|
43
|
-
# Step 5: Create directories
|
|
44
|
-
FileUtils.mkdir_p(configuration.partials_dir)
|
|
45
|
-
FileUtils.mkdir_p(configuration.vendor_dir)
|
|
46
|
-
puts "ā Created #{configuration.partials_dir}"
|
|
47
|
-
puts "ā Created #{configuration.vendor_dir}"
|
|
48
|
-
|
|
49
|
-
# Step 6: Generate webpack config if it doesn't exist
|
|
50
|
-
unless File.exist?(configuration.webpack_config_path)
|
|
51
|
-
generate_webpack_config!
|
|
52
|
-
puts "ā Generated webpack.config.js"
|
|
53
|
-
else
|
|
54
|
-
puts "ā webpack.config.js already exists"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Step 7: Set up vendor system and inject into layout
|
|
58
|
-
setup_vendor_system!
|
|
59
|
-
inject_islands_helper_into_layout!
|
|
60
|
-
|
|
61
|
-
# Step 8: Add node_modules to .gitignore
|
|
62
|
-
ensure_node_modules_gitignored!
|
|
63
|
-
|
|
64
|
-
puts "\nš IslandjsRails initialized successfully!"
|
|
65
|
-
puts "\nš Next steps:"
|
|
66
|
-
puts "1. Install libraries: rails \"islandjs:install[react,19.2.0]\""
|
|
67
|
-
puts " rails \"islandjs:install[react-dom,19.2.0]\" "
|
|
68
|
-
puts "2. Start dev: yarn watch"
|
|
69
|
-
puts "3. Use components: <%= react_component('HelloWorld') %>"
|
|
70
|
-
puts "4. Build for prod: yarn build"
|
|
71
|
-
puts "5. Commit assets: git add public/islands_* && git add public/islands/*"
|
|
72
|
-
|
|
73
|
-
puts "\nš Rails 8 Ready: Commit your built assets for bulletproof deploys!"
|
|
74
|
-
puts "š” IslandjsRails is framework-agnostic - use React, Vue, or any UMD library!"
|
|
75
|
-
puts "š Ready to build!"
|
|
19
|
+
# Use new Vite-based installer
|
|
20
|
+
require_relative 'vite_installer'
|
|
21
|
+
installer = ViteInstaller.new
|
|
22
|
+
installer.install!
|
|
76
23
|
end
|
|
77
24
|
|
|
78
25
|
# Install a new island package
|
|
@@ -92,7 +39,7 @@ module IslandjsRails
|
|
|
92
39
|
return false unless success
|
|
93
40
|
|
|
94
41
|
global_name = detect_global_name(package_name)
|
|
95
|
-
|
|
42
|
+
update_vite_externals(package_name, global_name)
|
|
96
43
|
|
|
97
44
|
puts "ā
Successfully installed #{package_name}!"
|
|
98
45
|
|
|
@@ -118,9 +65,9 @@ module IslandjsRails
|
|
|
118
65
|
vendor_manager = IslandjsRails.vendor_manager
|
|
119
66
|
vendor_manager.install_package!(package_name, version)
|
|
120
67
|
|
|
121
|
-
# Update
|
|
68
|
+
# Update Vite externals
|
|
122
69
|
global_name = detect_global_name(package_name)
|
|
123
|
-
|
|
70
|
+
update_vite_externals(package_name, global_name)
|
|
124
71
|
|
|
125
72
|
puts "ā
Successfully updated #{package_name}!"
|
|
126
73
|
end
|
|
@@ -139,7 +86,7 @@ module IslandjsRails
|
|
|
139
86
|
vendor_manager = IslandjsRails.vendor_manager
|
|
140
87
|
vendor_manager.remove_package!(package_name)
|
|
141
88
|
|
|
142
|
-
|
|
89
|
+
update_vite_externals
|
|
143
90
|
puts "ā
Successfully removed #{package_name}!"
|
|
144
91
|
end
|
|
145
92
|
|
|
@@ -165,9 +112,9 @@ module IslandjsRails
|
|
|
165
112
|
# Install to vendor system
|
|
166
113
|
vendor_manager.install_package!(package_name, version)
|
|
167
114
|
|
|
168
|
-
# Update
|
|
115
|
+
# Update Vite externals
|
|
169
116
|
global_name = detect_global_name(package_name)
|
|
170
|
-
|
|
117
|
+
update_vite_externals(package_name, global_name)
|
|
171
118
|
end
|
|
172
119
|
|
|
173
120
|
puts "ā
Sync completed!"
|
|
@@ -220,16 +167,15 @@ module IslandjsRails
|
|
|
220
167
|
vendor_manager.send(:regenerate_vendor_partial!)
|
|
221
168
|
puts " ā Regenerated vendor partial"
|
|
222
169
|
|
|
223
|
-
#
|
|
224
|
-
|
|
225
|
-
puts " ā Reset webpack externals"
|
|
170
|
+
# Vite externals will be updated as packages are reinstalled
|
|
171
|
+
puts " ā Vite externals will be updated as packages are reinstalled"
|
|
226
172
|
|
|
227
173
|
# Reinstall all packages from package.json
|
|
228
174
|
installed_packages.each do |package_name, version|
|
|
229
175
|
puts " š¦ Reinstalling #{package_name}@#{version}..."
|
|
230
176
|
vendor_manager.install_package!(package_name, version)
|
|
231
177
|
global_name = detect_global_name(package_name)
|
|
232
|
-
|
|
178
|
+
update_vite_externals(package_name, global_name)
|
|
233
179
|
end
|
|
234
180
|
|
|
235
181
|
puts "ā
Clean completed!"
|
|
@@ -347,7 +293,7 @@ module IslandjsRails
|
|
|
347
293
|
File.exist?(partial_path_for(package_name))
|
|
348
294
|
end
|
|
349
295
|
|
|
350
|
-
# Get global name for a package (used by
|
|
296
|
+
# Get global name for a package (used by Vite externals)
|
|
351
297
|
def get_global_name_for_package(package_name)
|
|
352
298
|
detect_global_name(package_name)
|
|
353
299
|
end
|