shakapacker 9.0.0.beta.4 → 9.0.0.beta.6
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/.eslintignore +1 -0
- data/.github/workflows/claude-code-review.yml +1 -1
- data/.github/workflows/dummy.yml +4 -0
- data/.github/workflows/generator.yml +7 -0
- data/.github/workflows/node.yml +22 -0
- data/.github/workflows/ruby.yml +11 -0
- data/.github/workflows/test-bundlers.yml +27 -9
- data/.gitignore +20 -0
- data/.yalcignore +26 -0
- data/CHANGELOG.md +58 -40
- data/CONTRIBUTING.md +64 -0
- data/Gemfile.lock +1 -1
- data/README.md +80 -1
- data/docs/optional-peer-dependencies.md +198 -0
- data/docs/typescript.md +99 -0
- data/docs/v9_upgrade.md +79 -2
- data/lib/install/template.rb +8 -1
- data/lib/shakapacker/configuration.rb +58 -1
- data/lib/shakapacker/doctor.rb +751 -0
- data/lib/shakapacker/swc_migrator.rb +292 -0
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker.rb +1 -0
- data/lib/tasks/shakapacker/doctor.rake +8 -0
- data/lib/tasks/shakapacker/migrate_to_swc.rake +13 -0
- data/lib/tasks/shakapacker.rake +1 -0
- data/package/config.ts +162 -0
- data/package/{dev_server.js → dev_server.ts} +8 -5
- data/package/env.ts +67 -0
- data/package/environments/base.js +94 -117
- data/package/environments/base.ts +138 -0
- data/package/index.d.ts +3 -150
- data/package/{index.js → index.ts} +18 -8
- data/package/loaders.d.ts +28 -0
- data/package/types.ts +108 -0
- data/package/utils/configPath.ts +6 -0
- data/package/utils/{debug.js → debug.ts} +7 -7
- data/package/utils/defaultConfigPath.ts +4 -0
- data/package/utils/errorHelpers.ts +77 -0
- data/package/utils/{getStyleRule.js → getStyleRule.ts} +17 -20
- data/package/utils/helpers.ts +85 -0
- data/package/utils/{inliningCss.js → inliningCss.ts} +3 -3
- data/package/utils/{requireOrError.js → requireOrError.ts} +2 -2
- data/package/utils/snakeToCamelCase.ts +5 -0
- data/package/utils/typeGuards.ts +228 -0
- data/package/utils/{validateDependencies.js → validateDependencies.ts} +4 -4
- data/package/webpack-types.d.ts +33 -0
- data/package/webpackDevServerConfig.ts +117 -0
- data/package.json +112 -4
- data/test/peer-dependencies.sh +85 -0
- data/test/typescript/build.test.js +117 -0
- data/tsconfig.json +39 -0
- data/yarn.lock +1 -1
- metadata +34 -17
- data/package/config.js +0 -80
- data/package/env.js +0 -48
- data/package/utils/configPath.js +0 -4
- data/package/utils/defaultConfigPath.js +0 -2
- data/package/utils/helpers.js +0 -127
- data/package/utils/snakeToCamelCase.js +0 -5
- data/package/utils/validateCssModulesConfig.js +0 -91
- data/package/webpackDevServerConfig.js +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65a49f86249eeb2035e56d7f21da2d8e4edbe5a26da50b0a63a9534a720a84cf
|
4
|
+
data.tar.gz: 153cb1df867355c881a3a7fe31b3aed526355ff30f7eaaacb497d231cb5f3bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c237ee4221a14f19ae86067632ad00baaf1f05d3464c21804b8aa3fa7029429bc8d678d630f1762f940ea780f4ff81023c26d26342aa27380a461f1485f50b3d
|
7
|
+
data.tar.gz: b37633ed02a416c423bfb410b189b1ca7c508a162339e9def8401622c2ac198b4649ad0392795a9eb3301d6fc3d9858c2e39f1130b8c6bbd219887566126b91e
|
data/.eslintignore
CHANGED
@@ -50,5 +50,5 @@ jobs:
|
|
50
50
|
|
51
51
|
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
52
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:*)"'
|
53
|
+
claude_args: '--model claude-sonnet-4-5-20250929 --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
54
|
|
data/.github/workflows/dummy.yml
CHANGED
@@ -29,8 +29,12 @@ jobs:
|
|
29
29
|
- name: Install dependencies
|
30
30
|
run: |
|
31
31
|
bundle install
|
32
|
+
yarn install --frozen-lockfile --production=false
|
32
33
|
npm install -g yalc
|
33
34
|
cd spec/dummy && npm install
|
35
|
+
|
36
|
+
- name: Build TypeScript
|
37
|
+
run: yarn build
|
34
38
|
|
35
39
|
- name: Run tests
|
36
40
|
run: bundle exec rake run_spec:dummy
|
data/.github/workflows/node.yml
CHANGED
@@ -30,6 +30,25 @@ jobs:
|
|
30
30
|
|
31
31
|
- name: Node eslint
|
32
32
|
run: yarn lint
|
33
|
+
|
34
|
+
type-check:
|
35
|
+
name: TypeScript Type Checking
|
36
|
+
runs-on: ubuntu-latest
|
37
|
+
|
38
|
+
steps:
|
39
|
+
- uses: actions/checkout@v4
|
40
|
+
with:
|
41
|
+
persist-credentials: false
|
42
|
+
- uses: actions/setup-node@v4
|
43
|
+
with:
|
44
|
+
node-version: 20.x
|
45
|
+
cache: yarn
|
46
|
+
|
47
|
+
- name: Install dependencies
|
48
|
+
run: yarn --frozen-lockfile --non-interactive --prefer-offline
|
49
|
+
|
50
|
+
- name: TypeScript type check
|
51
|
+
run: yarn type-check
|
33
52
|
test:
|
34
53
|
name: Testing
|
35
54
|
strategy:
|
@@ -52,5 +71,8 @@ jobs:
|
|
52
71
|
- name: Install dependencies
|
53
72
|
run: yarn --frozen-lockfile --non-interactive --prefer-offline
|
54
73
|
|
74
|
+
- name: Build TypeScript
|
75
|
+
run: yarn build
|
76
|
+
|
55
77
|
- name: Jest Specs
|
56
78
|
run: yarn test
|
data/.github/workflows/ruby.yml
CHANGED
@@ -85,6 +85,17 @@ jobs:
|
|
85
85
|
ruby-version: ${{ matrix.ruby }}
|
86
86
|
rubygems: latest
|
87
87
|
bundler-cache: true
|
88
|
+
|
89
|
+
- uses: actions/setup-node@v4
|
90
|
+
with:
|
91
|
+
node-version: 20.x
|
92
|
+
cache: yarn
|
93
|
+
|
94
|
+
- name: Install Node dependencies
|
95
|
+
run: yarn install --frozen-lockfile --production=false
|
96
|
+
|
97
|
+
- name: Build TypeScript
|
98
|
+
run: yarn build
|
88
99
|
|
89
100
|
- name: Ruby specs
|
90
101
|
run: bundle exec rake run_spec:gem
|
@@ -27,12 +27,18 @@ jobs:
|
|
27
27
|
uses: actions/setup-node@v4
|
28
28
|
with:
|
29
29
|
node-version: '20'
|
30
|
-
cache: '
|
31
|
-
cache-dependency-path: spec/dummy/
|
30
|
+
cache: 'yarn'
|
31
|
+
cache-dependency-path: spec/dummy/yarn.lock
|
32
32
|
|
33
33
|
- name: Install yalc
|
34
34
|
run: npm install -g yalc
|
35
35
|
|
36
|
+
- name: Build TypeScript
|
37
|
+
run: |
|
38
|
+
cd ../..
|
39
|
+
yarn install --frozen-lockfile --production=false
|
40
|
+
yarn build
|
41
|
+
|
36
42
|
- name: Publish shakapacker to yalc
|
37
43
|
run: |
|
38
44
|
cd ../..
|
@@ -41,7 +47,7 @@ jobs:
|
|
41
47
|
- name: Install dependencies
|
42
48
|
run: |
|
43
49
|
yalc link shakapacker
|
44
|
-
|
50
|
+
yarn install
|
45
51
|
|
46
52
|
- name: Switch to Webpack
|
47
53
|
run: bin/test-bundler webpack
|
@@ -74,12 +80,18 @@ jobs:
|
|
74
80
|
uses: actions/setup-node@v4
|
75
81
|
with:
|
76
82
|
node-version: '20'
|
77
|
-
cache: '
|
78
|
-
cache-dependency-path: spec/dummy/
|
83
|
+
cache: 'yarn'
|
84
|
+
cache-dependency-path: spec/dummy/yarn.lock
|
79
85
|
|
80
86
|
- name: Install yalc
|
81
87
|
run: npm install -g yalc
|
82
88
|
|
89
|
+
- name: Build TypeScript
|
90
|
+
run: |
|
91
|
+
cd ../..
|
92
|
+
yarn install --frozen-lockfile --production=false
|
93
|
+
yarn build
|
94
|
+
|
83
95
|
- name: Publish shakapacker to yalc
|
84
96
|
run: |
|
85
97
|
cd ../..
|
@@ -88,7 +100,7 @@ jobs:
|
|
88
100
|
- name: Install dependencies
|
89
101
|
run: |
|
90
102
|
yalc link shakapacker
|
91
|
-
|
103
|
+
yarn install
|
92
104
|
|
93
105
|
- name: Switch to RSpack
|
94
106
|
run: bin/test-bundler rspack
|
@@ -121,12 +133,18 @@ jobs:
|
|
121
133
|
uses: actions/setup-node@v4
|
122
134
|
with:
|
123
135
|
node-version: '20'
|
124
|
-
cache: '
|
125
|
-
cache-dependency-path: spec/dummy/
|
136
|
+
cache: 'yarn'
|
137
|
+
cache-dependency-path: spec/dummy/yarn.lock
|
126
138
|
|
127
139
|
- name: Install yalc
|
128
140
|
run: npm install -g yalc
|
129
141
|
|
142
|
+
- name: Build TypeScript
|
143
|
+
run: |
|
144
|
+
cd ../..
|
145
|
+
yarn install --frozen-lockfile --production=false
|
146
|
+
yarn build
|
147
|
+
|
130
148
|
- name: Publish shakapacker to yalc
|
131
149
|
run: |
|
132
150
|
cd ../..
|
@@ -135,7 +153,7 @@ jobs:
|
|
135
153
|
- name: Install dependencies
|
136
154
|
run: |
|
137
155
|
yalc link shakapacker
|
138
|
-
|
156
|
+
yarn install
|
139
157
|
|
140
158
|
- name: Test switching between bundlers
|
141
159
|
run: |
|
data/.gitignore
CHANGED
@@ -14,3 +14,23 @@ gemfiles/*.lock
|
|
14
14
|
|
15
15
|
.yalc
|
16
16
|
yalc.lock
|
17
|
+
|
18
|
+
# TypeScript generated files
|
19
|
+
package/**/*.d.ts
|
20
|
+
package/**/*.d.ts.map
|
21
|
+
package/**/*.js.map
|
22
|
+
# Ignore compiled JS files from TypeScript sources
|
23
|
+
package/**/*.js
|
24
|
+
# Keep specific files that are not TypeScript-generated
|
25
|
+
!package/index.d.ts
|
26
|
+
!package/loaders.d.ts
|
27
|
+
!package/webpack-types.d.ts
|
28
|
+
!package/babel/preset.js
|
29
|
+
!package/babel/preset-react.js
|
30
|
+
!package/environments/*.js
|
31
|
+
!package/rules/*.js
|
32
|
+
!package/loaders/*.js
|
33
|
+
!package/plugins/*.js
|
34
|
+
!package/__mocks__/*.js
|
35
|
+
!package/utils/get_style_rule.js
|
36
|
+
!package/utils/node_modules.js
|
data/.yalcignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Yalc-specific ignore file
|
2
|
+
# Unlike .gitignore, we want to include generated JS files for yalc publish
|
3
|
+
|
4
|
+
# Ignore source TypeScript files since we're publishing compiled JS
|
5
|
+
package/**/*.ts
|
6
|
+
!package/**/*.d.ts
|
7
|
+
|
8
|
+
# Ignore map files
|
9
|
+
package/**/*.js.map
|
10
|
+
package/**/*.d.ts.map
|
11
|
+
|
12
|
+
# Ignore test files
|
13
|
+
**/*.test.js
|
14
|
+
**/*.spec.js
|
15
|
+
**/__tests__
|
16
|
+
**/__mocks__
|
17
|
+
|
18
|
+
# Ignore config and build files
|
19
|
+
.github
|
20
|
+
.vscode
|
21
|
+
.idea
|
22
|
+
*.log
|
23
|
+
node_modules
|
24
|
+
tmp
|
25
|
+
coverage
|
26
|
+
.DS_Store
|
data/CHANGELOG.md
CHANGED
@@ -9,54 +9,71 @@
|
|
9
9
|
## [Unreleased]
|
10
10
|
Changes since the last non-beta release.
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
## [v9.0.0-beta.4] - Unreleased
|
13
|
+
|
14
|
+
### ⚠️ Breaking Changes
|
15
|
+
|
16
|
+
1. **SWC is now the default JavaScript transpiler instead of Babel** ([PR 603](https://github.com/shakacode/shakapacker/pull/603) by [justin808](https://github.com/justin808))
|
17
|
+
- Babel dependencies are no longer included as peer dependencies
|
18
|
+
- Improves compilation speed by 20x
|
19
|
+
- **Migration for existing projects:**
|
20
|
+
- **Option 1 (Recommended):** Switch to SWC:
|
21
|
+
```yaml
|
22
|
+
# config/shakapacker.yml
|
23
|
+
javascript_transpiler: 'swc'
|
24
|
+
```
|
25
|
+
Then install: `npm install @swc/core swc-loader`
|
26
|
+
- **Option 2:** Keep using Babel:
|
27
|
+
```yaml
|
28
|
+
# config/shakapacker.yml
|
29
|
+
javascript_transpiler: 'babel'
|
30
|
+
```
|
31
|
+
|
32
|
+
2. **CSS Modules now use named exports by default**
|
33
|
+
- Configured with `namedExport: true` and `exportLocalsConvention: 'camelCase'`
|
34
|
+
- **JavaScript:** Use named imports: `import { className } from './styles.module.css'`
|
35
|
+
- **TypeScript:** Use namespace imports: `import * as styles from './styles.module.css'`
|
36
|
+
- Default imports (`import styles from '...'`) no longer work
|
37
|
+
- See [CSS Modules Export Mode documentation](./docs/css-modules-export-mode.md) for migration details
|
38
|
+
|
39
|
+
3. **Configuration option renamed from `webpack_loader` to `javascript_transpiler`**
|
40
|
+
- Better reflects its purpose of configuring JavaScript transpilation
|
41
|
+
- Old `webpack_loader` option deprecated but still supported with warning
|
16
42
|
|
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**: 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
|
48
43
|
### Added
|
44
|
+
- **Rspack support** as an alternative assets bundler to webpack
|
45
|
+
- Configure `assets_bundler: 'rspack'` in `shakapacker.yml`
|
46
|
+
- Faster Rust-based bundling with webpack-compatible APIs
|
47
|
+
- Built-in SWC loader and CSS extraction
|
48
|
+
- Automatic bundler detection in `bin/shakapacker`
|
49
|
+
- **Private output path** for server-side rendering bundles ([PR 592](https://github.com/shakacode/shakapacker/pull/592) by [justin808](https://github.com/justin808))
|
50
|
+
- Configure `private_output_path` for private server bundles
|
51
|
+
- **Enhanced TypeScript definitions** ([PR 602](https://github.com/shakacode/shakapacker/pull/602) by [justin808](https://github.com/justin808))
|
52
|
+
- Better IDE support and type safety
|
53
|
+
- **`rake shakapacker:doctor` diagnostic command** ([PR 609](https://github.com/shakacode/shakapacker/pull/609) by [justin808](https://github.com/justin808))
|
54
|
+
- Check for configuration issues and missing dependencies
|
55
|
+
- Identify missing loaders that cause build errors
|
56
|
+
- Particularly useful when migrating to v9 where peer dependencies are removed
|
57
|
+
- Detects transpiler-specific issues based on v9 changes
|
49
58
|
|
50
|
-
|
59
|
+
### Changed
|
60
|
+
- Configuration option renamed from `bundler` to `assets_bundler` (deprecated but supported)
|
61
|
+
- **Babel dependencies are now optional** instead of peer dependencies ([PR 603](https://github.com/shakacode/shakapacker/pull/603) by [justin808](https://github.com/justin808))
|
62
|
+
- Installed automatically only when `javascript_transpiler` is set to 'babel'
|
51
63
|
|
52
64
|
### Fixed
|
65
|
+
- Update webpack-dev-server to secure versions (^4.15.2 || ^5.2.2) ([PR 585](https://github.com/shakacode/shakapacker/pull/585) by [justin808](https://github.com/justin808))
|
66
|
+
|
67
|
+
## [v8.4.0] - September 8, 2024
|
53
68
|
|
69
|
+
### Added
|
70
|
+
- Support for subresource integrity. [PR 570](https://github.com/shakacode/shakapacker/pull/570) by [panagiotisplytas](https://github.com/panagiotisplytas).
|
71
|
+
|
72
|
+
### Fixed
|
54
73
|
- Install the latest major version of peer dependencies [PR 576](https://github.com/shakacode/shakapacker/pull/576) by [G-Rath](https://github.com/g-rath).
|
55
|
-
- Remove duplicate word in comment from generated `shakapacker.yml` config [PR 572](https://github.com/shakacode/shakapacker/pull/572) by [G-Rath](https://github.com/g-rath).
|
56
|
-
- fix: update webpack-dev-server to secure versions (^4.15.2 || ^5.2.2) [PR 585](https://github.com/shakacode/shakapacker/pull/585) by [justin808](https://github.com/justin808)
|
57
74
|
|
58
75
|
|
59
|
-
## [v8.3.0] - April
|
76
|
+
## [v8.3.0] - April 28, 2024
|
60
77
|
### Added
|
61
78
|
|
62
79
|
- Allow `webpack-assets-manifest` v6. [PR 562](https://github.com/shakacode/shakapacker/pull/562) by [tagliala](https://github.com/tagliala), [shoeyn](https://github.com/shoeyn).
|
@@ -467,7 +484,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
467
484
|
## v5.4.3 and prior changes from rails/webpacker
|
468
485
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
469
486
|
|
470
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/
|
487
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.0.0-beta.4...main
|
488
|
+
[v9.0.0-beta.4]: https://github.com/shakacode/shakapacker/compare/v8.4.0...v9.0.0-beta.4
|
471
489
|
[v8.4.0]: https://github.com/shakacode/shakapacker/compare/v8.3.0...v8.4.0
|
472
490
|
[v8.3.0]: https://github.com/shakacode/shakapacker/compare/v8.2.0...v8.3.0
|
473
491
|
[v8.2.0]: https://github.com/shakacode/shakapacker/compare/v8.1.0...v8.2.0
|
data/CONTRIBUTING.md
CHANGED
@@ -50,6 +50,34 @@ We welcome pull requests that fix bugs, add new features, or improve existing on
|
|
50
50
|
yarn install
|
51
51
|
```
|
52
52
|
|
53
|
+
## Understanding Optional Peer Dependencies
|
54
|
+
|
55
|
+
Shakapacker uses optional peer dependencies (via `peerDependenciesMeta`) for maximum flexibility:
|
56
|
+
|
57
|
+
- **All peer dependencies are optional** - Users only install what they need
|
58
|
+
- **No installation warnings** - Package managers won't warn about missing optional dependencies
|
59
|
+
- **Version constraints still apply** - When a package is installed, version compatibility is enforced
|
60
|
+
|
61
|
+
### When modifying dependencies:
|
62
|
+
1. Add new peer dependencies to both `peerDependencies` and `peerDependenciesMeta` (marking as optional)
|
63
|
+
2. Keep version ranges synchronized between `devDependencies` and `peerDependencies`
|
64
|
+
3. Test with multiple package managers: `npm`, `yarn`, and `pnpm`
|
65
|
+
|
66
|
+
### Testing peer dependency changes:
|
67
|
+
```bash
|
68
|
+
# Test with npm (no warnings expected)
|
69
|
+
cd /tmp && mkdir test-npm && cd test-npm
|
70
|
+
npm init -y && npm install /path/to/shakapacker
|
71
|
+
|
72
|
+
# Test with yarn (no warnings expected)
|
73
|
+
cd /tmp && mkdir test-yarn && cd test-yarn
|
74
|
+
yarn init -y && yarn add /path/to/shakapacker
|
75
|
+
|
76
|
+
# Test with pnpm (no warnings expected)
|
77
|
+
cd /tmp && mkdir test-pnpm && cd test-pnpm
|
78
|
+
pnpm init && pnpm add /path/to/shakapacker
|
79
|
+
```
|
80
|
+
|
53
81
|
## Making sure your changes pass all tests
|
54
82
|
|
55
83
|
There are several specs, covering different aspects of Shakapacker gem. You may run them locally or rely on GitHub CI actions configured to test the gem functionality if different Ruby, Rails, and Node environment.
|
@@ -125,3 +153,39 @@ To ensure that your installer works as expected, either you can run `bundle exec
|
|
125
153
|
3. Run `bundle exec rails shakapacker:install` to confirm that you got the right changes.
|
126
154
|
|
127
155
|
**Note:** Ensure that you use bundle exec otherwise the installed shakapacker gem will run and not the one you are working on.
|
156
|
+
|
157
|
+
## CI Workflows
|
158
|
+
|
159
|
+
Shakapacker uses GitHub Actions for continuous integration. The CI workflows use **Yarn** as the package manager for consistency and reliability.
|
160
|
+
|
161
|
+
### Package Manager Choice
|
162
|
+
|
163
|
+
The project uses Yarn in CI workflows for the following reasons:
|
164
|
+
- Deterministic dependency resolution with `yarn.lock`
|
165
|
+
- Faster installation with offline mirror support
|
166
|
+
- Better workspace support for monorepo-style testing
|
167
|
+
- Consistent behavior across different Node.js versions
|
168
|
+
|
169
|
+
### Key CI Workflow Files
|
170
|
+
|
171
|
+
- `.github/workflows/test-bundlers.yml` - Tests webpack, rspack, and bundler switching
|
172
|
+
- `.github/workflows/ruby.yml` - Ruby test suite across Ruby/Rails versions
|
173
|
+
- `.github/workflows/node.yml` - Node.js test suite across Node versions
|
174
|
+
- `.github/workflows/generator.yml` - Generator installation tests
|
175
|
+
|
176
|
+
All workflows use:
|
177
|
+
```yaml
|
178
|
+
- uses: actions/setup-node@v4
|
179
|
+
with:
|
180
|
+
cache: 'yarn'
|
181
|
+
cache-dependency-path: spec/dummy/yarn.lock
|
182
|
+
```
|
183
|
+
|
184
|
+
And install dependencies with:
|
185
|
+
```bash
|
186
|
+
yarn install
|
187
|
+
```
|
188
|
+
|
189
|
+
### Testing with Other Package Managers
|
190
|
+
|
191
|
+
While CI uses Yarn, the gem supports all major package managers (npm, yarn, pnpm, bun). Generator specs test against all package managers to ensure compatibility.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -199,6 +199,83 @@ Note, in v6+, most JS packages are peer dependencies. Thus, the installer will a
|
|
199
199
|
Previously, these "webpack" and "babel" packages were direct dependencies for `shakapacker`. By
|
200
200
|
making these peer dependencies, you have control over the versions used in your webpack and babel configs.
|
201
201
|
|
202
|
+
### Optional Peer Dependencies
|
203
|
+
|
204
|
+
All peer dependencies in Shakapacker are marked as optional via `peerDependenciesMeta`. This design decision ensures:
|
205
|
+
- **No warnings during package installation** when dependencies are not needed
|
206
|
+
- **Clear visibility of supported package versions** for upgrades
|
207
|
+
- **Flexibility to choose only the tools you need** (webpack vs rspack, babel vs swc vs esbuild)
|
208
|
+
|
209
|
+
The optional peer dependencies approach means you only install what you actually use, while still maintaining
|
210
|
+
version compatibility constraints when you do install those packages.
|
211
|
+
|
212
|
+
#### Required Dependencies by Configuration
|
213
|
+
|
214
|
+
Depending on your setup, you'll need different subsets of the optional peer dependencies:
|
215
|
+
|
216
|
+
**For Webpack + Babel (traditional setup):**
|
217
|
+
```json
|
218
|
+
{
|
219
|
+
"dependencies": {
|
220
|
+
"shakapacker": "^9.0.0",
|
221
|
+
"@babel/core": "^7.17.9",
|
222
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
223
|
+
"@babel/preset-env": "^7.16.11",
|
224
|
+
"@babel/runtime": "^7.17.9",
|
225
|
+
"babel-loader": "^8.2.4",
|
226
|
+
"compression-webpack-plugin": "^9.0.0",
|
227
|
+
"terser-webpack-plugin": "^5.3.1",
|
228
|
+
"webpack": "^5.76.0",
|
229
|
+
"webpack-assets-manifest": "^5.0.6",
|
230
|
+
"webpack-cli": "^5.0.0",
|
231
|
+
"webpack-dev-server": "^5.0.0"
|
232
|
+
}
|
233
|
+
}
|
234
|
+
```
|
235
|
+
|
236
|
+
**For Webpack + SWC (faster alternative):**
|
237
|
+
```json
|
238
|
+
{
|
239
|
+
"dependencies": {
|
240
|
+
"shakapacker": "^9.0.0",
|
241
|
+
"@swc/core": "^1.3.0",
|
242
|
+
"swc-loader": "^0.2.0",
|
243
|
+
"compression-webpack-plugin": "^9.0.0",
|
244
|
+
"terser-webpack-plugin": "^5.3.1",
|
245
|
+
"webpack": "^5.76.0",
|
246
|
+
"webpack-assets-manifest": "^5.0.6",
|
247
|
+
"webpack-cli": "^5.0.0",
|
248
|
+
"webpack-dev-server": "^5.0.0"
|
249
|
+
}
|
250
|
+
}
|
251
|
+
```
|
252
|
+
|
253
|
+
**For Rspack + SWC (10x faster bundling):**
|
254
|
+
```json
|
255
|
+
{
|
256
|
+
"dependencies": {
|
257
|
+
"shakapacker": "^9.0.0",
|
258
|
+
"@rspack/core": "^1.0.0",
|
259
|
+
"@rspack/cli": "^1.0.0",
|
260
|
+
"@swc/core": "^1.3.0",
|
261
|
+
"swc-loader": "^0.2.0",
|
262
|
+
"rspack-manifest-plugin": "^5.0.0"
|
263
|
+
}
|
264
|
+
}
|
265
|
+
```
|
266
|
+
|
267
|
+
**For CSS/Sass processing (add to any config above):**
|
268
|
+
```json
|
269
|
+
{
|
270
|
+
"dependencies": {
|
271
|
+
"css-loader": "^6.8.1",
|
272
|
+
"mini-css-extract-plugin": "^2.0.0",
|
273
|
+
"sass": "^1.50.0",
|
274
|
+
"sass-loader": "^13.0.0"
|
275
|
+
}
|
276
|
+
}
|
277
|
+
```
|
278
|
+
|
202
279
|
## Concepts
|
203
280
|
|
204
281
|
At its core, Shakapacker's essential function is to:
|
@@ -657,11 +734,13 @@ See also [Customizing Babel Config](./docs/customizing_babel_config.md) for an e
|
|
657
734
|
|
658
735
|
#### TypeScript
|
659
736
|
|
737
|
+
**📚 TypeScript Support:** See the **[TypeScript Documentation](./docs/typescript.md)** for type-safe configuration.
|
738
|
+
|
660
739
|
```bash
|
661
740
|
npm install typescript @babel/preset-typescript
|
662
741
|
```
|
663
742
|
|
664
|
-
Babel won
|
743
|
+
Babel won't perform any type-checking on TypeScript code. To optionally use type-checking run:
|
665
744
|
|
666
745
|
```bash
|
667
746
|
npm install fork-ts-checker-webpack-plugin
|