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.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +6 -9
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +6 -8
  4. data/.github/workflows/claude-code-review.yml +4 -5
  5. data/.github/workflows/claude.yml +1 -2
  6. data/.github/workflows/dummy.yml +4 -4
  7. data/.github/workflows/generator.yml +9 -9
  8. data/.github/workflows/node.yml +11 -2
  9. data/.github/workflows/ruby.yml +16 -16
  10. data/.github/workflows/test-bundlers.yml +9 -9
  11. data/.gitignore +4 -0
  12. data/CHANGELOG.md +19 -4
  13. data/CLAUDE.md +6 -1
  14. data/CONTRIBUTING.md +0 -1
  15. data/Gemfile.lock +1 -1
  16. data/README.md +14 -14
  17. data/TODO.md +10 -2
  18. data/TODO_v9.md +13 -3
  19. data/bin/export-bundler-config +1 -1
  20. data/conductor-setup.sh +1 -1
  21. data/conductor.json +1 -1
  22. data/docs/cdn_setup.md +13 -8
  23. data/docs/common-upgrades.md +2 -1
  24. data/docs/configuration.md +630 -0
  25. data/docs/css-modules-export-mode.md +120 -100
  26. data/docs/customizing_babel_config.md +16 -16
  27. data/docs/deployment.md +18 -0
  28. data/docs/developing_shakapacker.md +6 -0
  29. data/docs/optional-peer-dependencies.md +9 -4
  30. data/docs/peer-dependencies.md +17 -6
  31. data/docs/precompile_hook.md +342 -0
  32. data/docs/react.md +57 -47
  33. data/docs/releasing.md +0 -2
  34. data/docs/rspack.md +25 -21
  35. data/docs/rspack_migration_guide.md +335 -8
  36. data/docs/sprockets.md +1 -0
  37. data/docs/style_loader_vs_mini_css.md +12 -12
  38. data/docs/subresource_integrity.md +13 -7
  39. data/docs/transpiler-performance.md +40 -19
  40. data/docs/troubleshooting.md +0 -2
  41. data/docs/typescript-migration.md +48 -39
  42. data/docs/typescript.md +12 -8
  43. data/docs/using_esbuild_loader.md +10 -10
  44. data/docs/v6_upgrade.md +33 -20
  45. data/docs/v7_upgrade.md +8 -6
  46. data/docs/v8_upgrade.md +13 -12
  47. data/docs/v9_upgrade.md +2 -1
  48. data/eslint.config.fast.js +134 -0
  49. data/eslint.config.js +140 -0
  50. data/knip.ts +54 -0
  51. data/lib/install/bin/export-bundler-config +1 -1
  52. data/lib/install/config/shakapacker.yml +16 -5
  53. data/lib/shakapacker/compiler.rb +80 -0
  54. data/lib/shakapacker/configuration.rb +33 -5
  55. data/lib/shakapacker/dev_server_runner.rb +140 -1
  56. data/lib/shakapacker/doctor.rb +294 -65
  57. data/lib/shakapacker/instance.rb +8 -3
  58. data/lib/shakapacker/runner.rb +244 -8
  59. data/lib/shakapacker/version.rb +1 -1
  60. data/lib/tasks/shakapacker/doctor.rake +42 -2
  61. data/package/babel/preset.ts +7 -4
  62. data/package/config.ts +42 -30
  63. data/package/configExporter/cli.ts +799 -208
  64. data/package/configExporter/configFile.ts +520 -0
  65. data/package/configExporter/fileWriter.ts +12 -8
  66. data/package/configExporter/index.ts +9 -1
  67. data/package/configExporter/types.ts +36 -2
  68. data/package/configExporter/yamlSerializer.ts +22 -8
  69. data/package/dev_server.ts +1 -1
  70. data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +11 -5
  71. data/package/environments/base.ts +18 -13
  72. data/package/environments/development.ts +1 -1
  73. data/package/environments/production.ts +4 -1
  74. data/package/index.d.ts +50 -3
  75. data/package/index.d.ts.template +50 -0
  76. data/package/index.ts +7 -7
  77. data/package/loaders.d.ts +2 -2
  78. data/package/optimization/rspack.ts +1 -1
  79. data/package/plugins/rspack.ts +15 -4
  80. data/package/plugins/webpack.ts +7 -3
  81. data/package/rspack/index.ts +10 -2
  82. data/package/rules/raw.ts +3 -2
  83. data/package/rules/sass.ts +1 -1
  84. data/package/types/README.md +15 -13
  85. data/package/types/index.ts +5 -5
  86. data/package/types.ts +0 -1
  87. data/package/utils/defaultConfigPath.ts +4 -1
  88. data/package/utils/errorCodes.ts +129 -100
  89. data/package/utils/errorHelpers.ts +34 -29
  90. data/package/utils/getStyleRule.ts +5 -2
  91. data/package/utils/helpers.ts +21 -11
  92. data/package/utils/pathValidation.ts +43 -35
  93. data/package/utils/requireOrError.ts +1 -1
  94. data/package/utils/snakeToCamelCase.ts +1 -1
  95. data/package/utils/typeGuards.ts +132 -83
  96. data/package/utils/validateDependencies.ts +1 -1
  97. data/package/webpack-types.d.ts +3 -3
  98. data/package/webpackDevServerConfig.ts +22 -10
  99. data/package-lock.json +2 -2
  100. data/package.json +36 -28
  101. data/scripts/type-check-no-emit.js +1 -1
  102. data/test/configExporter/configFile.test.js +392 -0
  103. data/test/configExporter/integration.test.js +275 -0
  104. data/test/helpers.js +1 -1
  105. data/test/package/configExporter.test.js +154 -0
  106. data/test/package/helpers.test.js +2 -2
  107. data/test/package/rules/sass-version-parsing.test.js +71 -0
  108. data/test/package/rules/sass.test.js +2 -4
  109. data/test/package/rules/sass1.test.js +1 -3
  110. data/test/package/rules/sass16.test.js +23 -0
  111. data/tools/README.md +15 -5
  112. data/tsconfig.eslint.json +2 -9
  113. data/yarn.lock +1894 -1492
  114. metadata +19 -3
  115. data/.eslintignore +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ac40ff5ddf8db373b1de0efaf805a033d7ba87641d84bde529669761b8e64d2
4
- data.tar.gz: 5d0abb49ede8ad2aa37c94e9148e4def579c3eabb8c6e8d94a127796941ed559
3
+ metadata.gz: 673dbe7651111125cf2c4c408e128be24f73475825910473ced26eba32929f6e
4
+ data.tar.gz: 83af8568e4d40e9859483ee4d71d7164facb0c5c2131880912e0aa42143aa427
5
5
  SHA512:
6
- metadata.gz: 5309f5d9beef93aaa0434e0e8ab93118545ecad507ade518ab56a332980d804536e36762670d21245d67d6c60e126367b1ea4edd8e4766daf20c294871ea1263
7
- data.tar.gz: 4fb22afab6e203194018a1be9096aac472bffdbc08d58fc7a5b04a23c5e5d8c52084a17830d8ffb5156a6e4798de061f6f671474638616b7ffecd6c6348916f5
6
+ metadata.gz: 302f3c9f98e999524573103dbaf5ecdfc048f5c780a293ddcf1bfb0409a3779e83b0176070a2c7563f74be56a3c118e23812ba8065c048d1eb9fb9765d00a272
7
+ data.tar.gz: ff0f655f57a37baee93a04147b9e2d0e50fd0f2607c2413bac46a420275a0e40c302d41a1a3d4d38e35a0e1d70b525c60ecbc0a742c634c22b202b36d3422fd5
@@ -1,24 +1,21 @@
1
1
  ---
2
2
  name: Bug report
3
3
  about: Create a report for a crash or unexpected behavior.
4
- title: ''
4
+ title: ""
5
5
  labels: bug
6
- assignees: ''
7
-
6
+ assignees: ""
8
7
  ---
9
8
 
10
9
  _Notice: A bug is a crash or incorrect behavior. If you have a debugging or troubleshooting question, please open a discussion on the [Discussions Tab](https://github.com/shakacode/shakapacker/discussions). Otherwise, remove this line and fill out the following sections._
11
10
 
12
11
  ## Expected behavior:
13
12
 
14
-
15
13
  ## Actual behavior:
16
14
 
17
-
18
15
  ## Small, reproducible repo:
19
16
 
20
-
21
17
  ## Setup environment:
22
- - Ruby version:
23
- - Rails version:
24
- - Shakapacker version:
18
+
19
+ - Ruby version:
20
+ - Rails version:
21
+ - Shakapacker version:
@@ -1,21 +1,19 @@
1
1
  ---
2
2
  name: Feature request
3
3
  about: Create a request for new functionality
4
- title: ''
4
+ title: ""
5
5
  labels: enhancement
6
- assignees: ''
7
-
6
+ assignees: ""
8
7
  ---
9
8
 
10
9
  _Notice: A feature request describes a suggested improvement. If you have a debugging or troubleshooting question, please open a discussion on the [Discussions Tab](https://github.com/shakacode/shakapacker/discussions). Otherwise, remove this line and fill out the following sections._
11
10
 
12
11
  ## Desired behavior:
13
12
 
14
-
15
13
  ## Actual behavior:
16
14
 
17
-
18
15
  ## Setup environment:
19
- - Ruby version:
20
- - Rails version:
21
- - Shakapacker version:
16
+
17
+ - Ruby version:
18
+ - Rails version:
19
+ - Shakapacker version:
@@ -17,14 +17,14 @@ jobs:
17
17
  # github.event.pull_request.user.login == 'external-contributor' ||
18
18
  # github.event.pull_request.user.login == 'new-developer' ||
19
19
  # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20
-
20
+
21
21
  runs-on: ubuntu-latest
22
22
  permissions:
23
23
  contents: read
24
24
  pull-requests: read
25
25
  issues: read
26
26
  id-token: write
27
-
27
+
28
28
  steps:
29
29
  - name: Checkout repository
30
30
  uses: actions/checkout@v4
@@ -43,12 +43,11 @@ jobs:
43
43
  - Performance considerations
44
44
  - Security concerns
45
45
  - Test coverage
46
-
46
+
47
47
  Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
48
48
 
49
49
  Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
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
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
-
@@ -35,7 +35,7 @@ jobs:
35
35
  uses: anthropics/claude-code-action@v1
36
36
  with:
37
37
  claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38
-
38
+
39
39
  # This is an optional setting that allows Claude to read CI results on PRs
40
40
  additional_permissions: |
41
41
  actions: read
@@ -47,4 +47,3 @@ jobs:
47
47
  # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48
48
  # or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
49
49
  # claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
50
-
@@ -3,7 +3,7 @@ name: Dummy specs
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
8
 
9
9
  concurrency:
@@ -21,10 +21,10 @@ jobs:
21
21
  persist-credentials: false
22
22
  - uses: actions/setup-node@v4
23
23
  with:
24
- node-version: '20'
24
+ node-version: "20"
25
25
  - uses: ruby/setup-ruby@v1
26
26
  with:
27
- ruby-version: '3.2'
27
+ ruby-version: "3.2"
28
28
  rubygems: latest
29
29
  - name: Install dependencies
30
30
  run: |
@@ -32,7 +32,7 @@ jobs:
32
32
  yarn install --frozen-lockfile --production=false
33
33
  npm install -g yalc
34
34
  cd spec/dummy && npm install
35
-
35
+
36
36
  - name: Build TypeScript
37
37
  run: yarn build
38
38
 
@@ -3,7 +3,7 @@ name: Generator specs
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
8
 
9
9
  concurrency:
@@ -18,7 +18,7 @@ jobs:
18
18
  strategy:
19
19
  matrix:
20
20
  os: [ubuntu-latest]
21
- ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
21
+ ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4"]
22
22
  gemfile:
23
23
  - gemfiles/Gemfile-rails.7.0.x
24
24
  - gemfiles/Gemfile-rails.7.1.x
@@ -28,17 +28,17 @@ jobs:
28
28
  # upcomming Rails versions, maybe before a release.
29
29
  #- gemfiles/Gemfile-rails-edge
30
30
  exclude:
31
- - ruby: '2.7'
31
+ - ruby: "2.7"
32
32
  gemfile: gemfiles/Gemfile-rails.7.2.x
33
- - ruby: '2.7'
33
+ - ruby: "2.7"
34
34
  gemfile: gemfiles/Gemfile-rails.8.0.x
35
- - ruby: '3.0'
35
+ - ruby: "3.0"
36
36
  gemfile: gemfiles/Gemfile-rails.7.2.x
37
- - ruby: '3.0'
37
+ - ruby: "3.0"
38
38
  gemfile: gemfiles/Gemfile-rails.8.0.x
39
- - ruby: '3.1'
39
+ - ruby: "3.1"
40
40
  gemfile: gemfiles/Gemfile-rails.8.0.x
41
- - ruby: '3.4'
41
+ - ruby: "3.4"
42
42
  gemfile: gemfiles/Gemfile-rails.7.0.x
43
43
 
44
44
  env:
@@ -57,7 +57,7 @@ jobs:
57
57
  with:
58
58
  node-version: 20.x
59
59
  cache: yarn
60
-
60
+
61
61
  - name: Install Node dependencies
62
62
  run: yarn install --frozen-lockfile --production=false
63
63
 
@@ -3,7 +3,7 @@ name: Node based checks
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
8
 
9
9
  concurrency:
@@ -31,6 +31,15 @@ jobs:
31
31
  - name: Node eslint
32
32
  run: yarn lint
33
33
 
34
+ - name: Prettier format check
35
+ run: yarn prettier --check .
36
+
37
+ - name: Detect dead code
38
+ run: yarn knip
39
+
40
+ - name: Detect dead code in production
41
+ run: yarn knip:production
42
+
34
43
  type-check:
35
44
  name: TypeScript Type Checking
36
45
  runs-on: ubuntu-latest
@@ -54,7 +63,7 @@ jobs:
54
63
  strategy:
55
64
  matrix:
56
65
  os: [ubuntu-latest]
57
- node: [18.x, 20.x, 22.x]
66
+ node: [20.x, 22.x]
58
67
 
59
68
  runs-on: ${{ matrix.os }}
60
69
 
@@ -3,7 +3,7 @@ name: Ruby based checks
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
8
 
9
9
  concurrency:
@@ -23,7 +23,7 @@ jobs:
23
23
  run: rm -f Gemfile.lock
24
24
  - uses: ruby/setup-ruby@v1
25
25
  with:
26
- ruby-version: '3.4'
26
+ ruby-version: "3.4"
27
27
  rubygems: latest
28
28
  bundler-cache: true
29
29
 
@@ -36,7 +36,7 @@ jobs:
36
36
  strategy:
37
37
  matrix:
38
38
  os: [ubuntu-latest]
39
- ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
39
+ ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4"]
40
40
  gemfile:
41
41
  - gemfiles/Gemfile-rails.6.0.x
42
42
  - gemfiles/Gemfile-rails.6.1.x
@@ -48,29 +48,29 @@ jobs:
48
48
  # upcomming Rails versions, maybe before a release.
49
49
  #- gemfiles/Gemfile-rails-edge
50
50
  exclude:
51
- - ruby: '2.7'
51
+ - ruby: "2.7"
52
52
  gemfile: gemfiles/Gemfile-rails.7.2.x
53
- - ruby: '2.7'
53
+ - ruby: "2.7"
54
54
  gemfile: gemfiles/Gemfile-rails.8.0.x
55
- - ruby: '3.0'
55
+ - ruby: "3.0"
56
56
  gemfile: gemfiles/Gemfile-rails.7.2.x
57
- - ruby: '3.0'
57
+ - ruby: "3.0"
58
58
  gemfile: gemfiles/Gemfile-rails.8.0.x
59
- - ruby: '3.1'
59
+ - ruby: "3.1"
60
60
  gemfile: gemfiles/Gemfile-rails.6.0.x
61
- - ruby: '3.1'
61
+ - ruby: "3.1"
62
62
  gemfile: gemfiles/Gemfile-rails.8.0.x
63
- - ruby: '3.2'
63
+ - ruby: "3.2"
64
64
  gemfile: gemfiles/Gemfile-rails.6.0.x
65
- - ruby: '3.3'
65
+ - ruby: "3.3"
66
66
  gemfile: gemfiles/Gemfile-rails.6.0.x
67
- - ruby: '3.3'
67
+ - ruby: "3.3"
68
68
  gemfile: gemfiles/Gemfile-rails.6.1.x
69
- - ruby: '3.4'
69
+ - ruby: "3.4"
70
70
  gemfile: gemfiles/Gemfile-rails.6.0.x
71
- - ruby: '3.4'
71
+ - ruby: "3.4"
72
72
  gemfile: gemfiles/Gemfile-rails.6.1.x
73
- - ruby: '3.4'
73
+ - ruby: "3.4"
74
74
  gemfile: gemfiles/Gemfile-rails.7.0.x
75
75
 
76
76
  env:
@@ -85,7 +85,7 @@ jobs:
85
85
  ruby-version: ${{ matrix.ruby }}
86
86
  rubygems: latest
87
87
  bundler-cache: true
88
-
88
+
89
89
  - uses: actions/setup-node@v4
90
90
  with:
91
91
  node-version: 20.x
@@ -19,15 +19,15 @@ jobs:
19
19
  - name: Setup Ruby
20
20
  uses: ruby/setup-ruby@v1
21
21
  with:
22
- ruby-version: '3.2'
22
+ ruby-version: "3.2"
23
23
  bundler-cache: true
24
24
  working-directory: spec/dummy
25
25
 
26
26
  - name: Setup Node
27
27
  uses: actions/setup-node@v4
28
28
  with:
29
- node-version: '20'
30
- cache: 'yarn'
29
+ node-version: "20"
30
+ cache: "yarn"
31
31
  cache-dependency-path: spec/dummy/yarn.lock
32
32
 
33
33
  - name: Install yalc
@@ -72,15 +72,15 @@ jobs:
72
72
  - name: Setup Ruby
73
73
  uses: ruby/setup-ruby@v1
74
74
  with:
75
- ruby-version: '3.2'
75
+ ruby-version: "3.2"
76
76
  bundler-cache: true
77
77
  working-directory: spec/dummy
78
78
 
79
79
  - name: Setup Node
80
80
  uses: actions/setup-node@v4
81
81
  with:
82
- node-version: '20'
83
- cache: 'yarn'
82
+ node-version: "20"
83
+ cache: "yarn"
84
84
  cache-dependency-path: spec/dummy/yarn.lock
85
85
 
86
86
  - name: Install yalc
@@ -125,15 +125,15 @@ jobs:
125
125
  - name: Setup Ruby
126
126
  uses: ruby/setup-ruby@v1
127
127
  with:
128
- ruby-version: '3.2'
128
+ ruby-version: "3.2"
129
129
  bundler-cache: true
130
130
  working-directory: spec/dummy
131
131
 
132
132
  - name: Setup Node
133
133
  uses: actions/setup-node@v4
134
134
  with:
135
- node-version: '20'
136
- cache: 'yarn'
135
+ node-version: "20"
136
+ cache: "yarn"
137
137
  cache-dependency-path: spec/dummy/yarn.lock
138
138
 
139
139
  - name: Install yalc
data/.gitignore CHANGED
@@ -5,6 +5,7 @@
5
5
  node_modules
6
6
  .byebug_history
7
7
  /spec/test_app/tmp
8
+ /test/tmp
8
9
  yarn-debug.log*
9
10
  yarn-error.log*
10
11
  .yarn-integrity
@@ -16,6 +17,9 @@ gemfiles/*.lock
16
17
  .yalc
17
18
  yalc.lock
18
19
 
20
+ # npm pack tarballs
21
+ *.tgz
22
+
19
23
  # Config exporter output directory
20
24
  shakapacker-config-exports/
21
25
 
data/CHANGELOG.md CHANGED
@@ -11,7 +11,23 @@
11
11
 
12
12
  Changes since the last non-beta release.
13
13
 
14
- ## [v9.1.1] - October 9, 2025
14
+ ### Changed
15
+
16
+ - Allow ESLint v9 and migrated to flat config format. [PR #677](https://github.com/shakacode/shakapacker/pull/677) by [justin808](https://github.com/justin808).
17
+
18
+ ### Fixed
19
+
20
+ - Fixed rspack native bindings installation issue when switching bundlers. [PR #672](https://github.com/shakacode/shakapacker/pull/672) by [justin808](https://github.com/justin808).
21
+ - Running `rake shakapacker:switch_bundler rspack -- --install-deps` now properly installs platform-specific native bindings
22
+ - Fixes "Cannot find native binding" error when switching to rspack
23
+ - Fixed Rails constant error when using custom environments like staging. [PR #681](https://github.com/shakacode/shakapacker/pull/681) by [justin808](https://github.com/justin808).
24
+ - `RAILS_ENV=staging` no longer causes "uninitialized constant Shakapacker::Instance::Rails" error
25
+ - Shakapacker now works in non-Rails contexts (like standalone runner)
26
+ - Fixed TypeScript type definitions to export proper types instead of `any`. [PR #684](https://github.com/shakacode/shakapacker/pull/684) by [justin808](https://github.com/justin808).
27
+ - Previously `package/index.d.ts` was exporting all types as `any`, breaking IDE autocomplete
28
+ - Now properly exports typed interfaces for `WebpackConfig`, `RspackConfig`, etc.
29
+
30
+ ## [v9.2.0] - October 9, 2025
15
31
 
16
32
  ### Added
17
33
 
@@ -116,7 +132,6 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
116
132
  ### ⚠️ Breaking Changes
117
133
 
118
134
  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))
119
-
120
135
  - Babel dependencies are no longer included as peer dependencies
121
136
  - Improves compilation speed by 20x
122
137
  - **Migration for existing projects:**
@@ -133,7 +148,6 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
133
148
  ```
134
149
 
135
150
  2. **CSS Modules now use named exports by default** ([PR 599](https://github.com/shakacode/shakapacker/pull/599))
136
-
137
151
  - **JavaScript:** Use named imports: `import { className } from './styles.module.css'`
138
152
  - **TypeScript:** Use namespace imports: `import * as styles from './styles.module.css'`
139
153
  - To keep the old behavior with default imports, see [CSS Modules Export Mode documentation](./docs/css-modules-export-mode.md) for configuration instructions
@@ -399,7 +413,6 @@ See the [v8 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
399
413
 
400
414
  - Set `source_entry_path` to `packs` and `nested_entries` to `true` in`shakapacker.yml` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
401
415
  - Dev server configuration is modified to follow [webpack recommended configurations](https://webpack.js.org/configuration/dev-server/) for dev server. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha):
402
-
403
416
  - Deprecated `https` entry is removed from the default configuration file, allowing to set `server` or `https` as per the project requirements. For more detail, check webpack documentation. The `https` entry can be effective only if there is no `server` entry in the config file.
404
417
  - `allowed_hosts` is now set to `auto` instead of `all` by default.
405
418
 
@@ -667,6 +680,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
667
680
  See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
668
681
 
669
682
  [Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.0.0...main
683
+ [v9.2.0]: https://github.com/shakacode/shakapacker/compare/v9.1.0...v9.2.0
684
+ [v9.1.0]: https://github.com/shakacode/shakapacker/compare/v9.0.0...v9.1.0
670
685
  [v9.0.0]: https://github.com/shakacode/shakapacker/compare/v8.4.0...v9.0.0
671
686
  [v8.4.0]: https://github.com/shakacode/shakapacker/compare/v8.3.0...v8.4.0
672
687
  [v8.3.0]: https://github.com/shakacode/shakapacker/compare/v8.2.0...v8.3.0
data/CLAUDE.md CHANGED
@@ -1,29 +1,34 @@
1
1
  # Shakapacker Project Guidelines
2
2
 
3
3
  ## Critical Requirements
4
+
4
5
  - **ALWAYS end all files with a trailing newline character.** This is required by the project's linting rules.
5
6
  - **ALWAYS use `bundle exec` prefix when running Ruby commands** (rubocop, rspec, rake, etc.)
6
7
  - **ALWAYS run `bundle exec rubocop` before committing Ruby changes**
7
8
  - **ALWAYS run `yarn lint` before committing JavaScript changes**
8
9
 
9
10
  ## Testing
11
+
10
12
  - Run corresponding RSpec tests when changing source files
11
13
  - For example, when changing `lib/shakapacker/foo.rb`, run `spec/shakapacker/foo_spec.rb`
12
14
  - Run the full test suite with `bundle exec rspec` before pushing
13
15
 
14
16
  ## Code Style
17
+
15
18
  - Follow existing code conventions in the file you're editing
16
19
  - Use the project's existing patterns and utilities
17
20
  - No unnecessary comments unless requested
18
21
  - Keep changes focused and minimal - avoid extraneous diffs
19
22
 
20
23
  ## Git Workflow
24
+
21
25
  - Create feature branches for all changes
22
26
  - Never push directly to main branch
23
27
  - Create small, focused PRs that are easy to review
24
28
  - Always create a PR immediately after pushing changes
25
29
 
26
30
  ## Shakapacker-Specific
31
+
27
32
  - This gem supports both webpack and rspack configurations
28
33
  - Test changes with both bundlers when modifying core functionality
29
- - Be aware of the dual package.json/Gemfile dependency management
34
+ - Be aware of the dual package.json/Gemfile dependency management
data/CONTRIBUTING.md CHANGED
@@ -72,7 +72,6 @@ yarn lint --cache
72
72
 
73
73
  1. Install [Yarn](https://classic.yarnpkg.com/)
74
74
  2. To test your changes on a Rails test project do the following steps:
75
-
76
75
  - For Ruby gem, update `Gemfile` and point the `shakapacker` to the locally developing Shakapacker project:
77
76
  ```ruby
78
77
  gem 'shakapacker', path: "relative_or_absolute_path_to_local_shakapacker"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shakapacker (9.2.0)
4
+ shakapacker (9.3.0.beta.0)
5
5
  activesupport (>= 5.2)
6
6
  package_json
7
7
  rack-proxy (>= 0.6.1)
data/README.md CHANGED
@@ -70,6 +70,7 @@ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=
70
70
  - [Concepts](#concepts)
71
71
  - [Usage](#usage)
72
72
  - [Configuration and Code](#configuration-and-code)
73
+ - [Configuration Guide](./docs/configuration.md)
73
74
  - [View Helpers](#view-helpers)
74
75
  - [View Helpers `javascript_pack_tag` and `stylesheet_pack_tag`](#view-helpers-javascript_pack_tag-and-stylesheet_pack_tag)
75
76
  - [View Helpers `append_javascript_pack_tag`, `prepend_javascript_pack_tag` and `append_stylesheet_pack_tag`](#view-helper-append_javascript_pack_tag-prepend_javascript_pack_tag-and-append_stylesheet_pack_tag)
@@ -314,6 +315,8 @@ At its core, Shakapacker's essential function is to:
314
315
 
315
316
  ### Configuration and Code
316
317
 
318
+ **📖 For a comprehensive guide to all configuration options, see [Configuration Guide](./docs/configuration.md)**
319
+
317
320
  You will need your file system to correspond to the setup of your `config/shakapacker.yml` file.
318
321
 
319
322
  Suppose you have the following configuration:
@@ -348,13 +351,20 @@ public/packs # webpack output
348
351
 
349
352
  Webpack intelligently includes only necessary files. In this example, the file `packs/application.js` would reference `../src/my_component.js`
350
353
 
351
- `nested_entries` allows you to have webpack entry points nested in subdirectories. This defaults to true as of shakapacker v7. With `nested_entries: false`, you can have your entire `source_path` used for your source (using the `source_entry_path: /`) and you place files at the top level that you want as entry points. `nested_entries: true` allows you to have entries that are in subdirectories. This is useful if you have entries that are generated, so you can have a `generated` subdirectory and easily separate generated files from the rest of your codebase.
354
+ The `nested_entries` option allows webpack entry points in subdirectories (defaults to `true`). See the [Configuration Guide](./docs/configuration.md#nested_entries) for details.
355
+
356
+ The `useContentHash` option enables content-based cache busting. It's disabled by default (except in production) to speed up development builds. See the [Configuration Guide](./docs/configuration.md#usecontenthash) for details.
357
+
358
+ #### Precompile Hook
359
+
360
+ Shakapacker supports running custom commands before compilation via the `precompile_hook` configuration option.
352
361
 
353
- To enable/disable the usage of contentHash in any node environment (specified using the `NODE_ENV` environment variable), add/modify `useContentHash` with a boolean value in `config/shakapacker.yml`. This feature is disabled for all environments except production by default. You may not disable the content hash for a `NODE_ENV` of production as that would break the browser caching of assets. Notice that despite the possibility of enabling this option for the development environment, [it is not recommended](https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling).
362
+ For configuration details, see [precompile_hook in the Configuration Guide](./docs/configuration.md#precompile_hook).
363
+ For complete usage guide, see the [Precompile Hook Guide](./docs/precompile_hook.md).
354
364
 
355
365
  #### Setting custom config path
356
366
 
357
- You can use the environment variable `SHAKAPACKER_CONFIG` to enforce a particular path to the config file rather than the default `config/shakapacker.yml`.
367
+ You can use the `SHAKAPACKER_CONFIG` environment variable to specify a custom config file path. See [Environment Variables in the Configuration Guide](./docs/configuration.md#environment-variables) for this and other configuration options.
358
368
 
359
369
  ### View Helpers
360
370
 
@@ -583,11 +593,7 @@ Shakapacker ships with two different strategies that are used to determine wheth
583
593
  - `digest` - This strategy calculates SHA1 digest of files in your watched paths (see below). The calculated digest is then stored in a temp file. To check whether the assets need to be recompiled, Shakapacker calculates the SHA1 of the watched files and compares it with the one stored. If the digests are equal, no recompilation occurs. If the digests are different or the temp file is missing, files are recompiled.
584
594
  - `mtime` - This strategy looks at the last "modified at" timestamps of both files AND directories in your watched paths. The timestamp of the most recent file or directory is then compared with the timestamp of `manifest.json` file generated. If the manifest file timestamp is newer than one of the most recently modified files or directories in the watched paths, no recompilation occurs. If the manifest file is older, files are recompiled.
585
595
 
586
- The `mtime` strategy is generally faster than the `digest` one, but it requires stable timestamps, this makes it perfect for a development environment, such as needing to rebuild bundles for tests, or if you're not changing frontend assets much.
587
-
588
- In production or CI environments, the `digest` strategy is more suitable, unless you are using incremental builds or caching and can guarantee that the timestamps will not change after e.g. cache restore. However, many production or CI environments will explicitly compile assets, so `compile: false` is more appropriate. Otherwise, you'll waste time either checking file timestamps or computing digests.
589
-
590
- You can control what strategy is used by the `compiler_strategy` option in `shakapacker.yml` config file. By default `mtime` strategy is used in development environment, `digest` is used elsewhere.
596
+ The `compiler_strategy` option determines how Shakapacker checks if assets need recompilation (`mtime` for development, `digest` for production). See the [Configuration Guide](./docs/configuration.md#compiler_strategy) for detailed comparison and recommendations.
591
597
 
592
598
  > [!NOTE]
593
599
  >
@@ -1241,12 +1247,6 @@ The following companies support our Open Source projects, and ShakaCode uses the
1241
1247
  <img alt="BrowserStack" src="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png" height="55px">
1242
1248
  </picture>
1243
1249
  </a>
1244
- <a href="https://railsautoscale.com">
1245
- <img src="https://user-images.githubusercontent.com/4244251/184881144-95c2c25c-9879-4069-864d-4e67d6ed39d2.png" alt="Rails Autoscale" height="55px">
1246
- </a>
1247
1250
  <a href="https://www.honeybadger.io">
1248
1251
  <img src="https://user-images.githubusercontent.com/4244251/184881133-79ee9c3c-8165-4852-958e-31687b9536f4.png" alt="Honeybadger" height="55px">
1249
1252
  </a>
1250
- <a href="https://reviewable.io">
1251
- <img src="https://user-images.githubusercontent.com/20628911/230848305-c94510a4-82d7-468f-bf9f-eeb81d3f2ce0.png" alt="Reviewable" height="55px">
1252
- </a>
data/TODO.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # TypeScript Migration Status
2
2
 
3
3
  ## ✅ Completed (PR #602)
4
+
4
5
  - Enhanced `package/index.d.ts` with comprehensive type definitions
5
6
  - Added TypeScript type packages for better IDE support
6
7
  - Improved Config and DevServerConfig interfaces
@@ -12,39 +13,46 @@
12
13
  ## 📋 Next Steps (Issue #605)
13
14
 
14
15
  ### Phase 2: Core Module Conversion
16
+
15
17
  - [ ] Convert `package/config.js` to TypeScript
16
- - [ ] Convert `package/env.js` to TypeScript
18
+ - [ ] Convert `package/env.js` to TypeScript
17
19
  - [ ] Convert `package/index.js` to TypeScript
18
20
  - [ ] Convert `package/utils/helpers.js` to TypeScript
19
21
 
20
22
  ### Phase 3: Environment & Build System
23
+
21
24
  - [ ] Convert environment files (base, development, production, test)
22
25
  - [ ] Convert dev_server.js
23
26
  - [ ] Convert webpackDevServerConfig.js
24
27
 
25
28
  ### Phase 4: Rules & Loaders (PR #620) ✅
29
+
26
30
  - [x] Convert all files in `package/rules/`
27
31
  - [x] Convert all files in `package/plugins/`
28
32
  - [x] Convert all files in `package/optimization/`
29
33
 
30
34
  ### Phase 5: Framework-Specific Modules ✅
35
+
31
36
  - [x] Convert rspack support files
32
37
  - [x] Convert swc support files
33
38
  - [x] Convert esbuild support files
34
39
  - [x] Convert babel preset
35
40
 
36
41
  ### Phase 6: Final Cleanup ✅
42
+
37
43
  - [x] Add TypeScript linting with @typescript-eslint
38
44
  - [x] Verify strict mode is enabled (already configured)
39
45
  - [x] Update documentation
40
46
 
41
47
  ## Why Gradual Migration?
48
+
42
49
  - **Lower risk**: Each phase can be tested independently
43
50
  - **Team learning**: Get familiar with TypeScript incrementally
44
51
  - **Immediate value**: Type definitions already provide IDE benefits
45
52
  - **No breaking changes**: Users unaffected during migration
46
53
 
47
54
  ## Related Links
55
+
48
56
  - Original issue: #200
49
57
  - Initial PR: #602
50
- - Next steps issue: #605
58
+ - Next steps issue: #605