shakapacker 9.0.0.beta.0 → 9.0.0.beta.3
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/claude-code-review.yml +54 -0
- data/.github/workflows/claude.yml +50 -0
- data/.github/workflows/dummy.yml +3 -3
- data/.github/workflows/test-bundlers.yml +152 -0
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +15 -3
- data/CLAUDE.md +29 -0
- data/Gemfile.lock +1 -1
- data/README.md +42 -1
- data/Rakefile +39 -4
- 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/rspack.md +7 -7
- data/docs/rspack_migration_guide.md +202 -0
- data/docs/using_esbuild_loader.md +3 -3
- data/docs/using_swc_loader.md +5 -3
- data/docs/v6_upgrade.md +10 -0
- data/docs/v9_upgrade.md +185 -0
- data/lib/install/bin/shakapacker +3 -17
- data/lib/install/config/shakapacker.yml +9 -4
- data/lib/shakapacker/configuration.rb +75 -3
- data/lib/shakapacker/dev_server_runner.rb +19 -9
- data/lib/shakapacker/manifest.rb +4 -3
- data/lib/shakapacker/rspack_runner.rb +4 -42
- data/lib/shakapacker/runner.rb +105 -11
- data/lib/shakapacker/utils/manager.rb +2 -0
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker/version_checker.rb +1 -1
- data/lib/shakapacker/webpack_runner.rb +4 -42
- data/lib/tasks/shakapacker/install.rake +6 -2
- data/package/config.js +24 -0
- data/package/environments/base.js +12 -2
- data/package/environments/development.js +52 -12
- data/package/environments/production.js +8 -3
- data/package/environments/test.js +5 -3
- data/package/index.d.ts +69 -30
- data/package/index.js +1 -1
- data/package/optimization/rspack.js +9 -5
- data/package/plugins/rspack.js +12 -28
- data/package/rspack/index.js +57 -0
- data/package/rules/babel.js +2 -2
- data/package/rules/esbuild.js +2 -2
- data/package/rules/raw.js +5 -5
- data/package/rules/rspack.js +77 -7
- data/package/rules/swc.js +2 -2
- data/package/utils/debug.js +49 -0
- data/package/utils/getStyleRule.js +19 -10
- data/package/utils/requireOrError.js +1 -1
- data/package/utils/validateCssModulesConfig.js +91 -0
- data/package/utils/validateDependencies.js +61 -0
- data/package/webpackDevServerConfig.js +2 -0
- data/package-lock.json +11966 -0
- data/package.json +9 -2
- data/test/package/rules/esbuild.test.js +1 -1
- data/test/package/rules/swc.test.js +1 -1
- data/tools/README.md +124 -0
- data/tools/css-modules-v9-codemod.js +179 -0
- data/yarn.lock +199 -81
- metadata +20 -3
- data/lib/install/bin/shakapacker-rspack +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 402395e802e7a185fd12d12e18a766cb4adcf87b1b04286a7e2c47bfec83a40d
|
4
|
+
data.tar.gz: 1364c179704bed61e68bf95583331059018b6c46b07681b00f288e4a7b2debd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cbcc1fe7b7a4a8440f5513e099480c376e3382c51fef3afde2f48929148090ae8d4c51c56dd009025f63fd0f4ec54c53eaa1f00fda9dc6851fb0e7ab3a1b56a
|
7
|
+
data.tar.gz: e642ec8b91aee622052ff52c7038f074b140aade21130af222311c47137382675a0c536b2a8134d03a4678480946696d9a417c5b8233d344d28f44795bba6431
|
@@ -0,0 +1,54 @@
|
|
1
|
+
name: Claude Code Review
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [opened, synchronize]
|
6
|
+
# Optional: Only run on specific file changes
|
7
|
+
# paths:
|
8
|
+
# - "src/**/*.ts"
|
9
|
+
# - "src/**/*.tsx"
|
10
|
+
# - "src/**/*.js"
|
11
|
+
# - "src/**/*.jsx"
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
claude-review:
|
15
|
+
# Optional: Filter by PR author
|
16
|
+
# if: |
|
17
|
+
# github.event.pull_request.user.login == 'external-contributor' ||
|
18
|
+
# github.event.pull_request.user.login == 'new-developer' ||
|
19
|
+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
|
20
|
+
|
21
|
+
runs-on: ubuntu-latest
|
22
|
+
permissions:
|
23
|
+
contents: read
|
24
|
+
pull-requests: read
|
25
|
+
issues: read
|
26
|
+
id-token: write
|
27
|
+
|
28
|
+
steps:
|
29
|
+
- name: Checkout repository
|
30
|
+
uses: actions/checkout@v4
|
31
|
+
with:
|
32
|
+
fetch-depth: 1
|
33
|
+
|
34
|
+
- name: Run Claude Code Review
|
35
|
+
id: claude-review
|
36
|
+
uses: anthropics/claude-code-action@v1
|
37
|
+
with:
|
38
|
+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
39
|
+
prompt: |
|
40
|
+
Please review this pull request and provide feedback on:
|
41
|
+
- Code quality and best practices
|
42
|
+
- Potential bugs or issues
|
43
|
+
- Performance considerations
|
44
|
+
- Security concerns
|
45
|
+
- Test coverage
|
46
|
+
|
47
|
+
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
|
48
|
+
|
49
|
+
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
|
50
|
+
|
51
|
+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
52
|
+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
|
53
|
+
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
|
54
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
name: Claude Code
|
2
|
+
|
3
|
+
on:
|
4
|
+
issue_comment:
|
5
|
+
types: [created]
|
6
|
+
pull_request_review_comment:
|
7
|
+
types: [created]
|
8
|
+
issues:
|
9
|
+
types: [opened, assigned]
|
10
|
+
pull_request_review:
|
11
|
+
types: [submitted]
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
claude:
|
15
|
+
if: |
|
16
|
+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
17
|
+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
18
|
+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
19
|
+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
permissions:
|
22
|
+
contents: read
|
23
|
+
pull-requests: read
|
24
|
+
issues: read
|
25
|
+
id-token: write
|
26
|
+
actions: read # Required for Claude to read CI results on PRs
|
27
|
+
steps:
|
28
|
+
- name: Checkout repository
|
29
|
+
uses: actions/checkout@v4
|
30
|
+
with:
|
31
|
+
fetch-depth: 1
|
32
|
+
|
33
|
+
- name: Run Claude Code
|
34
|
+
id: claude
|
35
|
+
uses: anthropics/claude-code-action@v1
|
36
|
+
with:
|
37
|
+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
38
|
+
|
39
|
+
# This is an optional setting that allows Claude to read CI results on PRs
|
40
|
+
additional_permissions: |
|
41
|
+
actions: read
|
42
|
+
|
43
|
+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
|
44
|
+
# prompt: 'Update the pull request description to include a summary of changes.'
|
45
|
+
|
46
|
+
# Optional: Add claude_args to customize behavior and configuration
|
47
|
+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
48
|
+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
|
49
|
+
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
|
50
|
+
|
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/.rubocop.yml
CHANGED
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.
|
@@ -8,10 +9,21 @@
|
|
8
9
|
## [Unreleased]
|
9
10
|
Changes since the last non-beta release.
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
### Added
|
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
|
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).
|
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.
|
20
|
+
- **BREAKING CHANGE**: CSS Modules are now configured with named exports (`namedExport: true` and `exportLocalsConvention: 'camelCase'`) to align with Next.js and modern tooling standards.
|
21
|
+
- **JavaScript**: Use named imports (`import { className } from './styles.module.css'`)
|
22
|
+
- **TypeScript**: Requires namespace imports (`import * as styles from './styles.module.css'`) due to TypeScript's inability to type dynamic named exports
|
23
|
+
- Note: Default imports (`import styles from '...'`) will no longer work as css-loader with `namedExport: true` doesn't generate a default export
|
24
|
+
- See the [CSS Modules Export Mode documentation](./docs/css-modules-export-mode.md) for detailed migration instructions and override options
|
25
|
+
|
26
|
+
## [v9.0.0.beta.2] - September 25, 2025
|
15
27
|
### Added
|
16
28
|
|
17
29
|
* 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,16 +14,51 @@ 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
|
-
"
|
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",
|
46
|
+
"bundle exec rspec"
|
47
|
+
])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Run specs in the dummy-rspack app"
|
52
|
+
task :dummy_rspack do
|
53
|
+
puts "Running dummy-rspack app specs"
|
54
|
+
spec_dummy_dir = Pathname.new(File.join("spec", "dummy-rspack")).realpath
|
55
|
+
Bundler.with_unbundled_env do
|
56
|
+
sh_in_dir(".", "yalc publish")
|
57
|
+
sh_in_dir(spec_dummy_dir, [
|
58
|
+
"bundle install",
|
59
|
+
"yalc link shakapacker",
|
60
|
+
"npm install",
|
61
|
+
"NODE_ENV=test RAILS_ENV=test npm exec --no -- rspack build --config config/rspack/rspack.config.js",
|
27
62
|
"bundle exec rspec"
|
28
63
|
])
|
29
64
|
end
|
@@ -35,7 +70,7 @@ namespace :run_spec do
|
|
35
70
|
end
|
36
71
|
|
37
72
|
desc "Run all specs"
|
38
|
-
task all_specs: %i[gem dummy generator] do
|
73
|
+
task all_specs: %i[gem dummy dummy_with_rspack dummy_rspack generator] do
|
39
74
|
puts "Completed all RSpec tests"
|
40
75
|
end
|
41
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
|