shakapacker 9.2.0 → 9.3.0.beta.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/.github/ISSUE_TEMPLATE/bug_report.md +6 -9
- data/.github/ISSUE_TEMPLATE/feature_request.md +6 -8
- data/.github/workflows/claude-code-review.yml +4 -5
- data/.github/workflows/claude.yml +1 -2
- data/.github/workflows/dummy.yml +4 -4
- data/.github/workflows/generator.yml +9 -9
- data/.github/workflows/node.yml +11 -2
- data/.github/workflows/ruby.yml +16 -16
- data/.github/workflows/test-bundlers.yml +9 -9
- data/.gitignore +4 -0
- data/CHANGELOG.md +19 -4
- data/CLAUDE.md +6 -1
- data/CONTRIBUTING.md +0 -1
- data/Gemfile.lock +1 -1
- data/README.md +14 -14
- data/TODO.md +10 -2
- data/TODO_v9.md +13 -3
- data/bin/export-bundler-config +1 -1
- data/conductor-setup.sh +1 -1
- data/conductor.json +1 -1
- data/docs/cdn_setup.md +13 -8
- data/docs/common-upgrades.md +2 -1
- data/docs/configuration.md +630 -0
- data/docs/css-modules-export-mode.md +120 -100
- data/docs/customizing_babel_config.md +16 -16
- data/docs/deployment.md +18 -0
- data/docs/developing_shakapacker.md +6 -0
- data/docs/optional-peer-dependencies.md +9 -4
- data/docs/peer-dependencies.md +17 -6
- data/docs/precompile_hook.md +342 -0
- data/docs/react.md +57 -47
- data/docs/releasing.md +0 -2
- data/docs/rspack.md +25 -21
- data/docs/rspack_migration_guide.md +335 -8
- data/docs/sprockets.md +1 -0
- data/docs/style_loader_vs_mini_css.md +12 -12
- data/docs/subresource_integrity.md +13 -7
- data/docs/transpiler-performance.md +40 -19
- data/docs/troubleshooting.md +0 -2
- data/docs/typescript-migration.md +48 -39
- data/docs/typescript.md +12 -8
- data/docs/using_esbuild_loader.md +10 -10
- data/docs/v6_upgrade.md +33 -20
- data/docs/v7_upgrade.md +8 -6
- data/docs/v8_upgrade.md +13 -12
- data/docs/v9_upgrade.md +2 -1
- data/eslint.config.fast.js +134 -0
- data/eslint.config.js +140 -0
- data/knip.ts +54 -0
- data/lib/install/bin/export-bundler-config +1 -1
- data/lib/install/config/shakapacker.yml +16 -5
- data/lib/shakapacker/compiler.rb +80 -0
- data/lib/shakapacker/configuration.rb +33 -5
- data/lib/shakapacker/dev_server_runner.rb +140 -1
- data/lib/shakapacker/doctor.rb +294 -65
- data/lib/shakapacker/instance.rb +8 -3
- data/lib/shakapacker/runner.rb +244 -8
- data/lib/shakapacker/version.rb +1 -1
- data/lib/tasks/shakapacker/doctor.rake +42 -2
- data/package/babel/preset.ts +7 -4
- data/package/config.ts +42 -30
- data/package/configExporter/cli.ts +799 -208
- data/package/configExporter/configFile.ts +520 -0
- data/package/configExporter/fileWriter.ts +12 -8
- data/package/configExporter/index.ts +9 -1
- data/package/configExporter/types.ts +36 -2
- data/package/configExporter/yamlSerializer.ts +22 -8
- data/package/dev_server.ts +1 -1
- data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +11 -5
- data/package/environments/base.ts +18 -13
- data/package/environments/development.ts +1 -1
- data/package/environments/production.ts +4 -1
- data/package/index.d.ts +50 -3
- data/package/index.d.ts.template +50 -0
- data/package/index.ts +7 -7
- data/package/loaders.d.ts +2 -2
- data/package/optimization/rspack.ts +1 -1
- data/package/plugins/rspack.ts +15 -4
- data/package/plugins/webpack.ts +7 -3
- data/package/rspack/index.ts +10 -2
- data/package/rules/raw.ts +3 -2
- data/package/rules/sass.ts +1 -1
- data/package/types/README.md +15 -13
- data/package/types/index.ts +5 -5
- data/package/types.ts +0 -1
- data/package/utils/defaultConfigPath.ts +4 -1
- data/package/utils/errorCodes.ts +129 -100
- data/package/utils/errorHelpers.ts +34 -29
- data/package/utils/getStyleRule.ts +5 -2
- data/package/utils/helpers.ts +21 -11
- data/package/utils/pathValidation.ts +43 -35
- data/package/utils/requireOrError.ts +1 -1
- data/package/utils/snakeToCamelCase.ts +1 -1
- data/package/utils/typeGuards.ts +132 -83
- data/package/utils/validateDependencies.ts +1 -1
- data/package/webpack-types.d.ts +3 -3
- data/package/webpackDevServerConfig.ts +22 -10
- data/package-lock.json +2 -2
- data/package.json +36 -28
- data/scripts/type-check-no-emit.js +1 -1
- data/test/configExporter/configFile.test.js +392 -0
- data/test/configExporter/integration.test.js +275 -0
- data/test/helpers.js +1 -1
- data/test/package/configExporter.test.js +154 -0
- data/test/package/helpers.test.js +2 -2
- data/test/package/rules/sass-version-parsing.test.js +71 -0
- data/test/package/rules/sass.test.js +2 -4
- data/test/package/rules/sass1.test.js +1 -3
- data/test/package/rules/sass16.test.js +23 -0
- data/tools/README.md +15 -5
- data/tsconfig.eslint.json +2 -9
- data/yarn.lock +1894 -1492
- metadata +19 -3
- data/.eslintignore +0 -5
data/TODO_v9.md
CHANGED
@@ -3,17 +3,21 @@
|
|
3
3
|
## CSS Modules Configuration Alignment
|
4
4
|
|
5
5
|
### Problem
|
6
|
+
|
6
7
|
Current CSS modules configuration causes TypeScript/webpack warnings because of default vs named export mismatch.
|
7
8
|
|
8
9
|
### Current Behavior (v8)
|
10
|
+
|
9
11
|
- CSS modules use default export: `import styles from './styles.module.css'`
|
10
12
|
- This causes warnings but works at runtime
|
11
13
|
- Warning example: `export 'default' (imported as 'style') was not found in './HelloWorld.module.css'`
|
12
14
|
|
13
15
|
### Proposed v9 Change
|
16
|
+
|
14
17
|
Align with Next.js and modern tooling by using named exports:
|
15
18
|
|
16
19
|
1. **Update css-loader configuration:**
|
20
|
+
|
17
21
|
```javascript
|
18
22
|
{
|
19
23
|
loader: 'css-loader',
|
@@ -30,30 +34,34 @@ Align with Next.js and modern tooling by using named exports:
|
|
30
34
|
css-loader only allows `'camelCaseOnly'` or `'dashesOnly'` when named exports are enabled.
|
31
35
|
|
32
36
|
2. **Update TypeScript types:**
|
37
|
+
|
33
38
|
- Ensure proper typing for CSS modules with named exports
|
34
39
|
- May need to update or generate `.d.ts` files for CSS modules
|
35
40
|
|
36
41
|
3. **Migration guide for users:**
|
42
|
+
|
37
43
|
- Document the breaking change
|
38
44
|
- Provide codemod or migration script to update imports from:
|
39
45
|
```javascript
|
40
|
-
import styles from
|
46
|
+
import styles from "./styles.module.css"
|
41
47
|
styles.className
|
42
48
|
```
|
43
49
|
to:
|
44
50
|
```javascript
|
45
|
-
import * as styles from
|
51
|
+
import * as styles from "./styles.module.css"
|
46
52
|
// or
|
47
|
-
import { className } from
|
53
|
+
import { className } from "./styles.module.css"
|
48
54
|
```
|
49
55
|
|
50
56
|
### Benefits
|
57
|
+
|
51
58
|
- Eliminates webpack/TypeScript warnings
|
52
59
|
- Better tree-shaking potential
|
53
60
|
- More explicit about what CSS classes are being used
|
54
61
|
- Easier interoperability with frameworks that support named exports
|
55
62
|
|
56
63
|
### Implementation Notes
|
64
|
+
|
57
65
|
- This is a BREAKING CHANGE and appropriate for major version bump
|
58
66
|
- Need to test with both webpack and rspack
|
59
67
|
- Consider providing a compatibility mode via configuration option
|
@@ -63,6 +71,7 @@ css-loader only allows `'camelCaseOnly'` or `'dashesOnly'` when named exports ar
|
|
63
71
|
## Related Issues from PR #597
|
64
72
|
|
65
73
|
### React Component Not Rendering (spec/dummy) - RESOLVED ✅
|
74
|
+
|
66
75
|
- **Issue**: React component was not rendering due to CSS module import mismatch
|
67
76
|
- **Symptoms**:
|
68
77
|
- Component wasn't rendering "Hello, Stranger!"
|
@@ -82,6 +91,7 @@ css-loader only allows `'camelCaseOnly'` or `'dashesOnly'` when named exports ar
|
|
82
91
|
- Interactive functionality restored
|
83
92
|
|
84
93
|
### Test Infrastructure
|
94
|
+
|
85
95
|
- Successfully implemented dual bundler support (webpack/rspack)
|
86
96
|
- test-bundler script working well with status command
|
87
97
|
- Consider adding more comprehensive tests for both bundlers
|
data/bin/export-bundler-config
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
3
|
// Minimal shim - all logic is in the TypeScript module
|
4
|
-
const { run } = require(
|
4
|
+
const { run } = require("shakapacker/configExporter")
|
5
5
|
|
6
6
|
run(process.argv.slice(2))
|
7
7
|
.then((exitCode) => process.exit(exitCode))
|
data/conductor-setup.sh
CHANGED
data/conductor.json
CHANGED
data/docs/cdn_setup.md
CHANGED
@@ -64,7 +64,7 @@ Add the `asset_host` setting to your `config/shakapacker.yml`:
|
|
64
64
|
production:
|
65
65
|
# ... other settings ...
|
66
66
|
asset_host: https://cdn.example.com
|
67
|
-
|
67
|
+
|
68
68
|
# You can also set different CDN hosts per environment
|
69
69
|
staging:
|
70
70
|
asset_host: https://staging-cdn.example.com
|
@@ -77,8 +77,8 @@ Configure in your Rails environment file (e.g., `config/environments/production.
|
|
77
77
|
```ruby
|
78
78
|
Rails.application.configure do
|
79
79
|
# ... other settings ...
|
80
|
-
|
81
|
-
# This will be used by Shakapacker if SHAKAPACKER_ASSET_HOST
|
80
|
+
|
81
|
+
# This will be used by Shakapacker if SHAKAPACKER_ASSET_HOST
|
82
82
|
# and asset_host in shakapacker.yml are not set
|
83
83
|
config.action_controller.asset_host = 'https://cdn.example.com'
|
84
84
|
end
|
@@ -95,6 +95,7 @@ RAILS_ENV=production bundle exec rails assets:precompile
|
|
95
95
|
```
|
96
96
|
|
97
97
|
This ensures that:
|
98
|
+
|
98
99
|
- Webpack's `publicPath` is set to your CDN URL
|
99
100
|
- Dynamic imports and code-split chunks load from the CDN
|
100
101
|
- Asset manifest references use CDN URLs
|
@@ -189,9 +190,9 @@ If using code splitting, verify dynamic chunks load from CDN:
|
|
189
190
|
|
190
191
|
```javascript
|
191
192
|
// This dynamic import should load from CDN
|
192
|
-
import(
|
193
|
+
import("./components/HeavyComponent").then((module) => {
|
193
194
|
// Check Network tab - chunk should load from CDN
|
194
|
-
})
|
195
|
+
})
|
195
196
|
```
|
196
197
|
|
197
198
|
## Troubleshooting
|
@@ -201,6 +202,7 @@ import('./components/HeavyComponent').then(module => {
|
|
201
202
|
**Problem**: Assets are still loading from your application domain.
|
202
203
|
|
203
204
|
**Solutions**:
|
205
|
+
|
204
206
|
1. Ensure you set `SHAKAPACKER_ASSET_HOST` **before** running `assets:precompile`
|
205
207
|
2. Clear Rails cache: `rails tmp:cache:clear`
|
206
208
|
3. Check the manifest.json file includes CDN URLs:
|
@@ -213,6 +215,7 @@ import('./components/HeavyComponent').then(module => {
|
|
213
215
|
**Problem**: Browser shows CORS errors when loading assets from CDN.
|
214
216
|
|
215
217
|
**Solutions**:
|
218
|
+
|
216
219
|
1. Configure your CDN to add CORS headers:
|
217
220
|
```
|
218
221
|
Access-Control-Allow-Origin: *
|
@@ -227,6 +230,7 @@ import('./components/HeavyComponent').then(module => {
|
|
227
230
|
**Problem**: Web fonts fail to load from CDN due to CORS.
|
228
231
|
|
229
232
|
**Solutions**:
|
233
|
+
|
230
234
|
1. Ensure CDN sends proper CORS headers for font files
|
231
235
|
2. In CloudFlare, create a page rule for `*.woff2`, `*.woff`, `*.ttf` files with CORS headers
|
232
236
|
3. Consider hosting fonts separately or using base64 encoding
|
@@ -277,6 +281,7 @@ production:
|
|
277
281
|
```
|
278
282
|
|
279
283
|
Ensure your CDN serves files with CORS headers:
|
284
|
+
|
280
285
|
```
|
281
286
|
Access-Control-Allow-Origin: *
|
282
287
|
```
|
@@ -339,7 +344,7 @@ production:
|
|
339
344
|
compile: false
|
340
345
|
cache_manifest: true
|
341
346
|
asset_host: <%= ENV.fetch('SHAKAPACKER_ASSET_HOST', 'https://cdn.example.com') %>
|
342
|
-
|
347
|
+
|
343
348
|
# Enable integrity checking
|
344
349
|
integrity:
|
345
350
|
enabled: true
|
@@ -352,7 +357,7 @@ production:
|
|
352
357
|
Rails.application.configure do
|
353
358
|
# Fallback if SHAKAPACKER_ASSET_HOST is not set
|
354
359
|
config.action_controller.asset_host = 'https://cdn.example.com'
|
355
|
-
|
360
|
+
|
356
361
|
# Ensure proper headers for CDN
|
357
362
|
config.public_file_server.headers = {
|
358
363
|
'Cache-Control' => 'public, max-age=31536000',
|
@@ -376,4 +381,4 @@ Setting up a CDN with Shakapacker involves:
|
|
376
381
|
3. Compiling assets with the CDN URL
|
377
382
|
4. Deploying and verifying the setup
|
378
383
|
|
379
|
-
The key is ensuring `SHAKAPACKER_ASSET_HOST` is set during asset compilation so webpack's `publicPath` is configured correctly for dynamic imports and code-split chunks.
|
384
|
+
The key is ensuring `SHAKAPACKER_ASSET_HOST` is set during asset compilation so webpack's `publicPath` is configured correctly for dynamic imports and code-split chunks.
|
data/docs/common-upgrades.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
This document provides step-by-step instructions for the most common upgrade scenarios in Shakapacker projects.
|
4
4
|
|
5
|
+
**📖 For configuration options, see the [Configuration Guide](./configuration.md)**
|
6
|
+
|
5
7
|
## Table of Contents
|
6
8
|
|
7
9
|
- [Migrating Package Managers](#migrating-package-managers)
|
@@ -580,7 +582,6 @@ For maximum performance improvements, you can combine multiple migrations:
|
|
580
582
|
This combination provides the best performance improvement (up to 50-70x faster builds):
|
581
583
|
|
582
584
|
1. **First, migrate to SWC** (while still on webpack)
|
583
|
-
|
584
585
|
- Follow [Migrating from Babel to SWC](#migrating-from-babel-to-swc)
|
585
586
|
- Test thoroughly
|
586
587
|
- This is a smaller change to validate first
|