shakapacker 9.0.0.beta.2 → 9.0.0.beta.4
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/.github/workflows/dummy.yml +3 -3
- data/.github/workflows/test-bundlers.yml +152 -0
- data/CHANGELOG.md +31 -2
- data/CLAUDE.md +29 -0
- data/Gemfile.lock +1 -1
- data/README.md +42 -1
- data/Rakefile +25 -7
- data/TODO.md +51 -0
- data/TODO_v9.md +84 -0
- data/conductor-setup.sh +58 -0
- data/conductor.json +7 -0
- data/docs/cdn_setup.md +379 -0
- data/docs/css-modules-export-mode.md +216 -86
- data/docs/deployment.md +10 -1
- data/docs/peer-dependencies.md +23 -3
- data/docs/transpiler-performance.md +179 -0
- data/docs/v6_upgrade.md +10 -0
- data/docs/v9_upgrade.md +228 -0
- data/lib/install/config/shakapacker.yml +8 -2
- data/lib/install/package.json +8 -0
- data/lib/install/template.rb +121 -51
- data/lib/shakapacker/configuration.rb +39 -0
- data/lib/shakapacker/version.rb +1 -1
- data/package/config.js +2 -2
- data/package/index.d.ts +12 -1
- data/package/rules/rspack.js +4 -0
- data/package/utils/getStyleRule.js +16 -7
- data/package/utils/helpers.js +66 -1
- data/package/utils/validateCssModulesConfig.js +91 -0
- data/package.json +9 -2
- data/test/package/rules/babel.test.js +16 -0
- data/tools/README.md +124 -0
- data/tools/css-modules-v9-codemod.js +179 -0
- data/yarn.lock +203 -85
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 173792ac146bcec2bdcea877d9449ab35935ec1cd61b04d8df1d02cf62325a29
|
4
|
+
data.tar.gz: 7d135bb3eb60f7a65723625dbc611c155122b2cd985a99a955f93d0f0f380d24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d4f23b01c785a479e53a3e8abcf8df1462243096b4fc14ed3c2b0fbd50096ac5e65b829ecc3dd3d40a6adc072541952ff1af3e74ed8ebce544eb771570c527
|
7
|
+
data.tar.gz: de3fa497d411233f46023ca903f2f7586701a97b4c08de85ec347064c0d2b355570ad9e8988993dc01024663a0c48264513b3a00f23287665c3acfcee25644a0
|
data/.github/workflows/dummy.yml
CHANGED
@@ -24,13 +24,13 @@ jobs:
|
|
24
24
|
node-version: '20'
|
25
25
|
- uses: ruby/setup-ruby@v1
|
26
26
|
with:
|
27
|
-
ruby-version: '3.
|
27
|
+
ruby-version: '3.2'
|
28
28
|
rubygems: latest
|
29
29
|
- name: Install dependencies
|
30
30
|
run: |
|
31
31
|
bundle install
|
32
|
-
|
33
|
-
|
32
|
+
npm install -g yalc
|
33
|
+
cd spec/dummy && npm install
|
34
34
|
|
35
35
|
- name: Run tests
|
36
36
|
run: bundle exec rake run_spec:dummy
|
@@ -0,0 +1,152 @@
|
|
1
|
+
name: Test Both Bundlers
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches: [master, main]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test-webpack:
|
10
|
+
name: Test with Webpack
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
defaults:
|
13
|
+
run:
|
14
|
+
working-directory: spec/dummy
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v4
|
18
|
+
|
19
|
+
- name: Setup Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: '3.2'
|
23
|
+
bundler-cache: true
|
24
|
+
working-directory: spec/dummy
|
25
|
+
|
26
|
+
- name: Setup Node
|
27
|
+
uses: actions/setup-node@v4
|
28
|
+
with:
|
29
|
+
node-version: '20'
|
30
|
+
cache: 'npm'
|
31
|
+
cache-dependency-path: spec/dummy/package-lock.json
|
32
|
+
|
33
|
+
- name: Install yalc
|
34
|
+
run: npm install -g yalc
|
35
|
+
|
36
|
+
- name: Publish shakapacker to yalc
|
37
|
+
run: |
|
38
|
+
cd ../..
|
39
|
+
yalc publish
|
40
|
+
|
41
|
+
- name: Install dependencies
|
42
|
+
run: |
|
43
|
+
yalc link shakapacker
|
44
|
+
npm ci
|
45
|
+
|
46
|
+
- name: Switch to Webpack
|
47
|
+
run: bin/test-bundler webpack
|
48
|
+
|
49
|
+
- name: Build with Webpack
|
50
|
+
run: bin/shakapacker
|
51
|
+
|
52
|
+
- name: Run tests with Webpack
|
53
|
+
run: |
|
54
|
+
bundle exec rspec
|
55
|
+
|
56
|
+
test-rspack:
|
57
|
+
name: Test with RSpack
|
58
|
+
runs-on: ubuntu-latest
|
59
|
+
defaults:
|
60
|
+
run:
|
61
|
+
working-directory: spec/dummy
|
62
|
+
|
63
|
+
steps:
|
64
|
+
- uses: actions/checkout@v4
|
65
|
+
|
66
|
+
- name: Setup Ruby
|
67
|
+
uses: ruby/setup-ruby@v1
|
68
|
+
with:
|
69
|
+
ruby-version: '3.2'
|
70
|
+
bundler-cache: true
|
71
|
+
working-directory: spec/dummy
|
72
|
+
|
73
|
+
- name: Setup Node
|
74
|
+
uses: actions/setup-node@v4
|
75
|
+
with:
|
76
|
+
node-version: '20'
|
77
|
+
cache: 'npm'
|
78
|
+
cache-dependency-path: spec/dummy/package-lock.json
|
79
|
+
|
80
|
+
- name: Install yalc
|
81
|
+
run: npm install -g yalc
|
82
|
+
|
83
|
+
- name: Publish shakapacker to yalc
|
84
|
+
run: |
|
85
|
+
cd ../..
|
86
|
+
yalc publish
|
87
|
+
|
88
|
+
- name: Install dependencies
|
89
|
+
run: |
|
90
|
+
yalc link shakapacker
|
91
|
+
npm ci
|
92
|
+
|
93
|
+
- name: Switch to RSpack
|
94
|
+
run: bin/test-bundler rspack
|
95
|
+
|
96
|
+
- name: Build with RSpack
|
97
|
+
run: bin/shakapacker
|
98
|
+
|
99
|
+
- name: Run tests with RSpack
|
100
|
+
run: |
|
101
|
+
bundle exec rspec
|
102
|
+
|
103
|
+
test-switching:
|
104
|
+
name: Test Bundler Switching
|
105
|
+
runs-on: ubuntu-latest
|
106
|
+
defaults:
|
107
|
+
run:
|
108
|
+
working-directory: spec/dummy
|
109
|
+
|
110
|
+
steps:
|
111
|
+
- uses: actions/checkout@v4
|
112
|
+
|
113
|
+
- name: Setup Ruby
|
114
|
+
uses: ruby/setup-ruby@v1
|
115
|
+
with:
|
116
|
+
ruby-version: '3.2'
|
117
|
+
bundler-cache: true
|
118
|
+
working-directory: spec/dummy
|
119
|
+
|
120
|
+
- name: Setup Node
|
121
|
+
uses: actions/setup-node@v4
|
122
|
+
with:
|
123
|
+
node-version: '20'
|
124
|
+
cache: 'npm'
|
125
|
+
cache-dependency-path: spec/dummy/package-lock.json
|
126
|
+
|
127
|
+
- name: Install yalc
|
128
|
+
run: npm install -g yalc
|
129
|
+
|
130
|
+
- name: Publish shakapacker to yalc
|
131
|
+
run: |
|
132
|
+
cd ../..
|
133
|
+
yalc publish
|
134
|
+
|
135
|
+
- name: Install dependencies
|
136
|
+
run: |
|
137
|
+
yalc link shakapacker
|
138
|
+
npm ci
|
139
|
+
|
140
|
+
- name: Test switching between bundlers
|
141
|
+
run: |
|
142
|
+
# Start with webpack
|
143
|
+
bin/test-bundler webpack
|
144
|
+
bin/shakapacker
|
145
|
+
|
146
|
+
# Switch to rspack
|
147
|
+
bin/test-bundler rspack
|
148
|
+
bin/shakapacker
|
149
|
+
|
150
|
+
# Switch back to webpack
|
151
|
+
bin/test-bundler webpack
|
152
|
+
bin/shakapacker
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
* For the changelog of versions prior to v6, see the [5.x stable branch of rails/webpacker](https://github.com/rails/webpacker/tree/5-x-stable).
|
2
|
+
* **Please see the [v9 Upgrade Guide](./docs/v9_upgrade.md) for upgrading to version 9 and accounting for breaking changes.**
|
2
3
|
* Please see the [v8 Upgrade Guide](./docs/v8_upgrade.md) for upgrading to version 8 and accounting for breaking changes.
|
3
4
|
* Please see the [v7 Upgrade Guide](./docs/v7_upgrade.md) for upgrading to new spelling in version 7.
|
4
5
|
* Please see the [v6 Upgrade Guide](./docs/v6_upgrade.md) to go from versions prior to v6.
|
@@ -10,12 +11,40 @@ Changes since the last non-beta release.
|
|
10
11
|
|
11
12
|
### Added
|
12
13
|
- Rspack support as an alternative assets bundler to webpack. Configure `assets_bundler: 'rspack'` in `shakapacker.yml` to use Rspack's faster Rust-based bundling with webpack-compatible APIs, built-in SWC loader, and CSS extraction. Automatic assets bundler detection in `bin/shakapacker` with fallback support for webpack configurations.
|
14
|
+
- Add `private_output_path` configuration option for server-side rendering bundles. This allows specifying a separate output directory for private server bundles that shouldn't be served publicly. [PR 592](https://github.com/shakacode/shakapacker/pull/592) by [justin808](https://github.com/justin808).
|
15
|
+
- Enhanced TypeScript type definitions for better IDE support and type safety. Improved Config and DevServerConfig interfaces with additional properties. [PR 602](https://github.com/shakacode/shakapacker/pull/602) by [justin808](https://github.com/justin808).
|
13
16
|
|
14
17
|
### Changed
|
15
18
|
- Configuration option renamed from `bundler` to `assets_bundler` to avoid confusion with Ruby's Bundler gem manager. The old `bundler` option is deprecated but still supported with a warning (not a breaking change).
|
16
19
|
- BREAKING CHANGE: Configuration option renamed from `webpack_loader` to `javascript_transpiler` to better reflect its purpose of configuring JavaScript transpilation regardless of the bundler used. The old `webpack_loader` option is deprecated but still supported with a warning.
|
17
|
-
|
18
|
-
|
20
|
+
- **BREAKING CHANGE**: SWC is now the default JavaScript transpiler instead of Babel. Babel dependencies are no longer included as peer dependencies. They are installed automatically only when `javascript_transpiler` is set to 'babel'. This reduces node_modules size and improves compilation speed by 20x. [PR 603](https://github.com/shakacode/shakapacker/pull/603) by [justin808](https://github.com/justin808).
|
21
|
+
|
22
|
+
**Migration for existing projects:**
|
23
|
+
- **Option 1 (Recommended):** Switch to SWC for 20x faster compilation:
|
24
|
+
```yaml
|
25
|
+
# config/shakapacker.yml
|
26
|
+
javascript_transpiler: 'swc'
|
27
|
+
```
|
28
|
+
Then install SWC: `npm install @swc/core swc-loader`
|
29
|
+
|
30
|
+
- **Option 2:** Keep using Babel (no changes needed):
|
31
|
+
```yaml
|
32
|
+
# config/shakapacker.yml
|
33
|
+
javascript_transpiler: 'babel'
|
34
|
+
```
|
35
|
+
Your existing babel packages in package.json will continue to work.
|
36
|
+
|
37
|
+
**For new projects:**
|
38
|
+
- SWC is installed by default (20x faster than Babel)
|
39
|
+
- To use Babel instead: Set `javascript_transpiler: 'babel'` before running `rails shakapacker:install`
|
40
|
+
- To use esbuild: Set `javascript_transpiler: 'esbuild'` and install with `npm install esbuild esbuild-loader`
|
41
|
+
- **BREAKING CHANGE**: CSS Modules are now configured with named exports (`namedExport: true` and `exportLocalsConvention: 'camelCase'`) to align with Next.js and modern tooling standards.
|
42
|
+
- **JavaScript**: Use named imports (`import { className } from './styles.module.css'`)
|
43
|
+
- **TypeScript**: Requires namespace imports (`import * as styles from './styles.module.css'`) due to TypeScript's inability to type dynamic named exports
|
44
|
+
- Note: Default imports (`import styles from '...'`) will no longer work as css-loader with `namedExport: true` doesn't generate a default export
|
45
|
+
- See the [CSS Modules Export Mode documentation](./docs/css-modules-export-mode.md) for detailed migration instructions and override options
|
46
|
+
|
47
|
+
## [v9.0.0.beta.2] - September 25, 2025
|
19
48
|
### Added
|
20
49
|
|
21
50
|
* Support for subresource integrity. [PR 570](https://github.com/shakacode/shakapacker/pull/570) by [panagiotisplytas](https://github.com/panagiotisplytas)
|
data/CLAUDE.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Shakapacker Project Guidelines
|
2
|
+
|
3
|
+
## Critical Requirements
|
4
|
+
- **ALWAYS end all files with a trailing newline character.** This is required by the project's linting rules.
|
5
|
+
- **ALWAYS use `bundle exec` prefix when running Ruby commands** (rubocop, rspec, rake, etc.)
|
6
|
+
- **ALWAYS run `bundle exec rubocop` before committing Ruby changes**
|
7
|
+
- **ALWAYS run `yarn lint` before committing JavaScript changes**
|
8
|
+
|
9
|
+
## Testing
|
10
|
+
- Run corresponding RSpec tests when changing source files
|
11
|
+
- For example, when changing `lib/shakapacker/foo.rb`, run `spec/shakapacker/foo_spec.rb`
|
12
|
+
- Run the full test suite with `bundle exec rspec` before pushing
|
13
|
+
|
14
|
+
## Code Style
|
15
|
+
- Follow existing code conventions in the file you're editing
|
16
|
+
- Use the project's existing patterns and utilities
|
17
|
+
- No unnecessary comments unless requested
|
18
|
+
- Keep changes focused and minimal - avoid extraneous diffs
|
19
|
+
|
20
|
+
## Git Workflow
|
21
|
+
- Create feature branches for all changes
|
22
|
+
- Never push directly to main branch
|
23
|
+
- Create small, focused PRs that are easy to review
|
24
|
+
- Always create a PR immediately after pushing changes
|
25
|
+
|
26
|
+
## Shakapacker-Specific
|
27
|
+
- This gem supports both webpack and rspack configurations
|
28
|
+
- Test changes with both bundlers when modifying core functionality
|
29
|
+
- Be aware of the dual package.json/Gemfile dependency management
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
# Shakapacker (v8)
|
2
|
+
---
|
3
|
+
|
4
|
+
_🚀 Shakapacker 9.0.0.beta.2 supports [Rspack](https://rspack.rs/)! 10x faster than webpack!_
|
5
|
+
|
6
|
+
---
|
2
7
|
|
3
8
|
_Official, actively maintained successor to [rails/webpacker](https://github.com/rails/webpacker). ShakaCode stands behind the long-term maintenance and development of this project for the Rails community._
|
4
9
|
|
@@ -926,6 +931,30 @@ source_path: frontend # packs are the files in frontend/
|
|
926
931
|
public_output_path: assets/packs # outputs to => public/assets/packs
|
927
932
|
```
|
928
933
|
|
934
|
+
For server-side rendering (SSR) scenarios where you need to generate bundles that should not be served publicly, you can use the `private_output_path` configuration:
|
935
|
+
|
936
|
+
```yml
|
937
|
+
# config/shakapacker.yml
|
938
|
+
private_output_path: ssr-generated # outputs to => ssr-generated/
|
939
|
+
```
|
940
|
+
|
941
|
+
This is particularly useful when working with libraries like React on Rails where server bundles need to be kept separate from client bundles.
|
942
|
+
|
943
|
+
#### Migration Guide for React on Rails Users
|
944
|
+
|
945
|
+
If you're using React on Rails with separate client and server bundles, you can now leverage the `private_output_path` configuration instead of using custom webpack configurations:
|
946
|
+
|
947
|
+
1. Update your `config/shakapacker.yml`:
|
948
|
+
```yml
|
949
|
+
# Before: both client and server bundles in public/
|
950
|
+
# After: separate directories
|
951
|
+
public_output_path: packs # Client bundles (publicly served)
|
952
|
+
private_output_path: ssr-bundles # Server bundles (not publicly served)
|
953
|
+
```
|
954
|
+
|
955
|
+
2. Update your webpack configuration to use the appropriate output path based on the bundle type
|
956
|
+
3. The validation ensures `private_output_path` and `public_output_path` are different to prevent configuration errors
|
957
|
+
|
929
958
|
Similarly, you can also control and configure `webpack-dev-server` settings from `config/shakapacker.yml` file:
|
930
959
|
|
931
960
|
```yml
|
@@ -993,7 +1022,19 @@ pnpm install --frozen-lockfile
|
|
993
1022
|
bun install --frozen-lockfile
|
994
1023
|
```
|
995
1024
|
|
996
|
-
|
1025
|
+
### CDN
|
1026
|
+
|
1027
|
+
Shakapacker supports serving JavaScript bundles and assets from a CDN. The key configuration is setting the `SHAKAPACKER_ASSET_HOST` environment variable (NOT the Rails `ASSET_HOST` variable).
|
1028
|
+
|
1029
|
+
For detailed CDN setup instructions, including CloudFlare configuration, troubleshooting, and advanced setups, see the [CDN Setup Guide](./docs/cdn_setup.md).
|
1030
|
+
|
1031
|
+
**Quick example:**
|
1032
|
+
```bash
|
1033
|
+
export SHAKAPACKER_ASSET_HOST=https://cdn.example.com
|
1034
|
+
RAILS_ENV=production bundle exec rails assets:precompile
|
1035
|
+
```
|
1036
|
+
|
1037
|
+
For more deployment documentation, see [Deployment](./docs/deployment.md).
|
997
1038
|
|
998
1039
|
## Example Apps
|
999
1040
|
* [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh)
|
data/Rakefile
CHANGED
@@ -14,17 +14,35 @@ namespace :run_spec do
|
|
14
14
|
sh("bundle exec rspec spec/shakapacker/*_spec.rb")
|
15
15
|
end
|
16
16
|
|
17
|
-
desc "Run specs in the dummy app"
|
17
|
+
desc "Run specs in the dummy app with webpack"
|
18
18
|
task :dummy do
|
19
|
-
puts "Running dummy app specs"
|
19
|
+
puts "Running dummy app specs with webpack"
|
20
20
|
spec_dummy_dir = Pathname.new(File.join("spec", "dummy")).realpath
|
21
21
|
Bundler.with_unbundled_env do
|
22
22
|
sh_in_dir(".", "yalc publish")
|
23
23
|
sh_in_dir(spec_dummy_dir, [
|
24
24
|
"bundle install",
|
25
25
|
"yalc link shakapacker",
|
26
|
-
"
|
27
|
-
"
|
26
|
+
"npm install",
|
27
|
+
"bin/test-bundler webpack",
|
28
|
+
"NODE_ENV=test RAILS_ENV=test bin/shakapacker",
|
29
|
+
"bundle exec rspec"
|
30
|
+
])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Run specs in the dummy app with rspack"
|
35
|
+
task :dummy_with_rspack do
|
36
|
+
puts "Running dummy app specs with rspack"
|
37
|
+
spec_dummy_dir = Pathname.new(File.join("spec", "dummy")).realpath
|
38
|
+
Bundler.with_unbundled_env do
|
39
|
+
sh_in_dir(".", "yalc publish")
|
40
|
+
sh_in_dir(spec_dummy_dir, [
|
41
|
+
"bundle install",
|
42
|
+
"yalc link shakapacker",
|
43
|
+
"npm install",
|
44
|
+
"bin/test-bundler rspack",
|
45
|
+
"NODE_ENV=test RAILS_ENV=test bin/shakapacker",
|
28
46
|
"bundle exec rspec"
|
29
47
|
])
|
30
48
|
end
|
@@ -39,8 +57,8 @@ namespace :run_spec do
|
|
39
57
|
sh_in_dir(spec_dummy_dir, [
|
40
58
|
"bundle install",
|
41
59
|
"yalc link shakapacker",
|
42
|
-
"
|
43
|
-
"NODE_ENV=test RAILS_ENV=test
|
60
|
+
"npm install",
|
61
|
+
"NODE_ENV=test RAILS_ENV=test npm exec --no -- rspack build --config config/rspack/rspack.config.js",
|
44
62
|
"bundle exec rspec"
|
45
63
|
])
|
46
64
|
end
|
@@ -52,7 +70,7 @@ namespace :run_spec do
|
|
52
70
|
end
|
53
71
|
|
54
72
|
desc "Run all specs"
|
55
|
-
task all_specs: %i[gem dummy dummy_rspack generator] do
|
73
|
+
task all_specs: %i[gem dummy dummy_with_rspack dummy_rspack generator] do
|
56
74
|
puts "Completed all RSpec tests"
|
57
75
|
end
|
58
76
|
end
|
data/TODO.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# TypeScript Migration Status
|
2
|
+
|
3
|
+
## ✅ Completed (PR #602)
|
4
|
+
- Enhanced `package/index.d.ts` with comprehensive type definitions
|
5
|
+
- Added TypeScript type packages for better IDE support
|
6
|
+
- Improved Config and DevServerConfig interfaces
|
7
|
+
- Added missing properties (private_output_path, inline_css, env_prefix, etc.)
|
8
|
+
- All tests passing
|
9
|
+
- Zero JavaScript modifications (no whitespace changes)
|
10
|
+
- Full backward compatibility maintained
|
11
|
+
|
12
|
+
## 📋 Next Steps (Issue #605)
|
13
|
+
|
14
|
+
### Phase 2: Core Module Conversion
|
15
|
+
- [ ] Convert `package/config.js` to TypeScript
|
16
|
+
- [ ] Convert `package/env.js` to TypeScript
|
17
|
+
- [ ] Convert `package/index.js` to TypeScript
|
18
|
+
- [ ] Convert `package/utils/helpers.js` to TypeScript
|
19
|
+
|
20
|
+
### Phase 3: Environment & Build System
|
21
|
+
- [ ] Convert environment files (base, development, production, test)
|
22
|
+
- [ ] Convert dev_server.js
|
23
|
+
- [ ] Convert webpackDevServerConfig.js
|
24
|
+
|
25
|
+
### Phase 4: Rules & Loaders
|
26
|
+
- [ ] Convert all files in `package/rules/`
|
27
|
+
- [ ] Convert all files in `package/plugins/`
|
28
|
+
- [ ] Convert all files in `package/optimization/`
|
29
|
+
|
30
|
+
### Phase 5: Framework-Specific Modules
|
31
|
+
- [ ] Convert rspack support files
|
32
|
+
- [ ] Convert swc support files
|
33
|
+
- [ ] Convert esbuild support files
|
34
|
+
- [ ] Convert babel preset
|
35
|
+
|
36
|
+
### Phase 6: Final Cleanup
|
37
|
+
- [ ] Convert remaining utilities
|
38
|
+
- [ ] Add TypeScript linting
|
39
|
+
- [ ] Enable strict mode
|
40
|
+
- [ ] Update documentation
|
41
|
+
|
42
|
+
## Why Gradual Migration?
|
43
|
+
- **Lower risk**: Each phase can be tested independently
|
44
|
+
- **Team learning**: Get familiar with TypeScript incrementally
|
45
|
+
- **Immediate value**: Type definitions already provide IDE benefits
|
46
|
+
- **No breaking changes**: Users unaffected during migration
|
47
|
+
|
48
|
+
## Related Links
|
49
|
+
- Original issue: #200
|
50
|
+
- Initial PR: #602
|
51
|
+
- Next steps issue: #605
|
data/TODO_v9.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Shakapacker v9 TODO List
|
2
|
+
|
3
|
+
## CSS Modules Configuration Alignment
|
4
|
+
|
5
|
+
### Problem
|
6
|
+
Current CSS modules configuration causes TypeScript/webpack warnings because of default vs named export mismatch.
|
7
|
+
|
8
|
+
### Current Behavior (v8)
|
9
|
+
- CSS modules use default export: `import styles from './styles.module.css'`
|
10
|
+
- This causes warnings but works at runtime
|
11
|
+
- Warning example: `export 'default' (imported as 'style') was not found in './HelloWorld.module.css'`
|
12
|
+
|
13
|
+
### Proposed v9 Change
|
14
|
+
Align with Next.js and modern tooling by using named exports:
|
15
|
+
|
16
|
+
1. **Update css-loader configuration:**
|
17
|
+
```javascript
|
18
|
+
{
|
19
|
+
loader: 'css-loader',
|
20
|
+
options: {
|
21
|
+
modules: {
|
22
|
+
namedExport: true,
|
23
|
+
exportLocalsConvention: 'camelCase'
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
```
|
28
|
+
|
29
|
+
2. **Update TypeScript types:**
|
30
|
+
- Ensure proper typing for CSS modules with named exports
|
31
|
+
- May need to update or generate `.d.ts` files for CSS modules
|
32
|
+
|
33
|
+
3. **Migration guide for users:**
|
34
|
+
- Document the breaking change
|
35
|
+
- Provide codemod or migration script to update imports from:
|
36
|
+
```javascript
|
37
|
+
import styles from './styles.module.css'
|
38
|
+
styles.className
|
39
|
+
```
|
40
|
+
to:
|
41
|
+
```javascript
|
42
|
+
import * as styles from './styles.module.css'
|
43
|
+
// or
|
44
|
+
import { className } from './styles.module.css'
|
45
|
+
```
|
46
|
+
|
47
|
+
### Benefits
|
48
|
+
- Eliminates webpack/TypeScript warnings
|
49
|
+
- Better tree-shaking potential
|
50
|
+
- More explicit about what CSS classes are being used
|
51
|
+
- Easier interoperability with frameworks that support named exports
|
52
|
+
|
53
|
+
### Implementation Notes
|
54
|
+
- This is a BREAKING CHANGE and appropriate for major version bump
|
55
|
+
- Need to test with both webpack and rspack
|
56
|
+
- Consider providing a compatibility mode via configuration option
|
57
|
+
|
58
|
+
---
|
59
|
+
|
60
|
+
## Related Issues from PR #597
|
61
|
+
|
62
|
+
### React Component Not Rendering (spec/dummy) - RESOLVED ✅
|
63
|
+
- **Issue**: React component was not rendering due to CSS module import mismatch
|
64
|
+
- **Symptoms**:
|
65
|
+
- Component wasn't rendering "Hello, Stranger!"
|
66
|
+
- Input field not rendered, making interactive test fail
|
67
|
+
- Only the static H1 "Hello, World!" was visible
|
68
|
+
- **Resolution**:
|
69
|
+
- Fixed CSS module import syntax from `import style from` to `import * as style from`
|
70
|
+
- This matched webpack's named exports configuration for CSS modules
|
71
|
+
- Tests now pass with both React 18.3.1 and webpack/rspack configurations
|
72
|
+
- **Root Cause**: CSS module import/export mismatch
|
73
|
+
- Webpack was configured to use named exports for CSS modules
|
74
|
+
- TypeScript code was using default import syntax
|
75
|
+
- This caused `style` to be undefined, breaking SSR and client rendering
|
76
|
+
- **Status**: FIXED
|
77
|
+
- All tests re-enabled and passing
|
78
|
+
- Both SSR and client-side rendering working
|
79
|
+
- Interactive functionality restored
|
80
|
+
|
81
|
+
### Test Infrastructure
|
82
|
+
- Successfully implemented dual bundler support (webpack/rspack)
|
83
|
+
- test-bundler script working well with status command
|
84
|
+
- Consider adding more comprehensive tests for both bundlers
|
data/conductor-setup.sh
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
|
4
|
+
echo "🔧 Setting up Shakapacker workspace..."
|
5
|
+
|
6
|
+
# Set up Ruby version if asdf is available
|
7
|
+
if command -v asdf &> /dev/null; then
|
8
|
+
echo "📝 Using asdf Ruby version management..."
|
9
|
+
# Ensure we have the right Ruby version file
|
10
|
+
echo "ruby 3.3.4" > .tool-versions
|
11
|
+
# Use asdf exec to run commands with the right Ruby version
|
12
|
+
BUNDLE_CMD="asdf exec bundle"
|
13
|
+
else
|
14
|
+
BUNDLE_CMD="bundle"
|
15
|
+
fi
|
16
|
+
|
17
|
+
# Check for required tools
|
18
|
+
if ! $BUNDLE_CMD --version &> /dev/null; then
|
19
|
+
echo "❌ Error: Ruby bundler is not installed"
|
20
|
+
echo "Please install bundler first: gem install bundler"
|
21
|
+
exit 1
|
22
|
+
fi
|
23
|
+
|
24
|
+
if ! command -v yarn &> /dev/null; then
|
25
|
+
echo "❌ Error: Yarn is not installed"
|
26
|
+
echo "Please install yarn first"
|
27
|
+
exit 1
|
28
|
+
fi
|
29
|
+
|
30
|
+
# Install Ruby dependencies
|
31
|
+
echo "📦 Installing Ruby dependencies..."
|
32
|
+
$BUNDLE_CMD install
|
33
|
+
|
34
|
+
# Install JavaScript dependencies
|
35
|
+
echo "📦 Installing JavaScript dependencies..."
|
36
|
+
yarn install
|
37
|
+
|
38
|
+
# Copy environment files if they exist in root
|
39
|
+
if [ -n "${CONDUCTOR_ROOT_PATH:-}" ]; then
|
40
|
+
if [ -f "$CONDUCTOR_ROOT_PATH/.env" ]; then
|
41
|
+
echo "📋 Copying .env file from root..."
|
42
|
+
cp "$CONDUCTOR_ROOT_PATH/.env" .env
|
43
|
+
fi
|
44
|
+
|
45
|
+
if [ -f "$CONDUCTOR_ROOT_PATH/.env.local" ]; then
|
46
|
+
echo "📋 Copying .env.local file from root..."
|
47
|
+
cp "$CONDUCTOR_ROOT_PATH/.env.local" .env.local
|
48
|
+
fi
|
49
|
+
fi
|
50
|
+
|
51
|
+
echo "✅ Workspace setup complete!"
|
52
|
+
echo ""
|
53
|
+
echo "Available commands:"
|
54
|
+
echo " - Run tests: bundle exec rspec"
|
55
|
+
echo " - Run specific test suites: bundle exec rake run_spec:gem"
|
56
|
+
echo " - Run JavaScript tests: yarn test"
|
57
|
+
echo " - Lint JavaScript: yarn lint"
|
58
|
+
echo " - Lint Ruby: bundle exec rubocop"
|