shakapacker 7.0.2 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/dummy.yml +4 -2
- data/.github/workflows/generator.yml +4 -2
- data/.github/workflows/jest.yml +5 -3
- data/.github/workflows/js-lint.yml +5 -3
- data/.github/workflows/rubocop.yml +4 -2
- data/.github/workflows/ruby-backward-compatibility.yml +5 -3
- data/.github/workflows/ruby.yml +5 -3
- data/CHANGELOG.md +15 -1
- data/CONTRIBUTING.md +3 -4
- data/README.md +37 -23
- data/docs/deployment.md +1 -1
- data/docs/react.md +4 -4
- data/docs/troubleshooting.md +4 -8
- data/docs/using_esbuild_loader.md +3 -5
- data/docs/v6_upgrade.md +1 -1
- data/docs/v7_upgrade.md +2 -2
- data/lib/install/template.rb +2 -2
- data/lib/shakapacker/compiler.rb +1 -1
- data/lib/shakapacker/deprecation_helper.rb +1 -1
- data/lib/shakapacker/dev_server_runner.rb +2 -1
- data/lib/shakapacker/utils/misc.rb +1 -1
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker/version_checker.rb +35 -2
- data/lib/shakapacker/webpack_runner.rb +4 -3
- data/lib/tasks/shakapacker/binstubs.rake +2 -2
- data/lib/tasks/shakapacker/check_binstubs.rake +7 -2
- data/lib/tasks/shakapacker/install.rake +2 -2
- data/package/__tests__/index.js +24 -0
- data/package/environments/__tests__/base-bc.js +1 -1
- data/package/environments/__tests__/development.js +9 -9
- data/package/environments/__tests__/production.js +12 -12
- data/package/index.d.ts +61 -0
- data/package/index.js +8 -2
- data/package.json +12 -1
- data/rakelib/release.rake +1 -1
- data/spec/backward_compatibility_specs/compiler_spec.rb +2 -2
- data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +5 -3
- data/spec/backward_compatibility_specs/configuration_spec.rb +16 -8
- data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +17 -16
- data/spec/backward_compatibility_specs/dev_server_spec.rb +1 -1
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +2 -0
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +2 -1
- data/spec/backward_compatibility_specs/helper_spec.rb +20 -20
- data/spec/backward_compatibility_specs/instance_spec.rb +3 -3
- data/spec/backward_compatibility_specs/manifest_spec.rb +12 -12
- data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +3 -3
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +9 -5
- data/spec/backward_compatibility_specs/webpack_runner_spec.rb +14 -18
- data/spec/dummy/config/webpack/commonWebpackConfig.js +1 -1
- data/spec/fixtures/beta_pnpm-lock.v7.yaml +116 -0
- data/spec/fixtures/beta_pnpm-lock.v8.yaml +2537 -0
- data/spec/fixtures/git_url_pnpm-lock.v7.yaml +126 -0
- data/spec/fixtures/git_url_pnpm-lock.v8.yaml +3728 -0
- data/spec/fixtures/github_url_pnpm-lock.v7.yaml +126 -0
- data/spec/fixtures/github_url_pnpm-lock.v8.yaml +3728 -0
- data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +18 -0
- data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +22 -0
- data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +117 -0
- data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +117 -0
- data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +116 -0
- data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/without_pnpm-lock.v7.yaml +23 -0
- data/spec/fixtures/without_pnpm-lock.v8.yaml +27 -0
- data/spec/generator_specs/generator_spec.rb +11 -7
- data/spec/shakapacker/compiler_spec.rb +2 -2
- data/spec/shakapacker/compiler_strategy_spec.rb +5 -3
- data/spec/shakapacker/configuration_spec.rb +16 -6
- data/spec/shakapacker/dev_server_runner_spec.rb +22 -16
- data/spec/shakapacker/dev_server_spec.rb +1 -1
- data/spec/shakapacker/digest_strategy_spec.rb +2 -0
- data/spec/shakapacker/engine_rake_tasks_spec.rb +2 -1
- data/spec/shakapacker/helper_spec.rb +20 -20
- data/spec/shakapacker/instance_spec.rb +2 -2
- data/spec/shakapacker/manifest_spec.rb +12 -12
- data/spec/shakapacker/mtime_strategy_spec.rb +3 -3
- data/spec/shakapacker/rake_tasks_spec.rb +6 -3
- data/spec/shakapacker/shakapacker_spec.rb +4 -4
- data/spec/shakapacker/version_checker_spec.rb +470 -123
- data/spec/shakapacker/webpack_runner_spec.rb +14 -18
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b52fbe18d6cc69e790f1432b93a8badee45c64229b7e0b5ad9bf6e7645c1c28c
|
4
|
+
data.tar.gz: 94ba2b7a48537e4b3ece200e2983975b444a340edff45b9af3544b1709375c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade899e22f00c9863302d2a9aa7e58549d057b07be50d34d853751cabf59a9d318a637240734854059b352110b20245361ec7d427488166b4e481639b90cb380
|
7
|
+
data.tar.gz: 6364f8d109c008da994d01f7ad553472a90d5392511b796ba7286502d5f3b6969ad225cbd8e3364fb86da6f2dc5b19524631399eebae982b43558444cb886a0e
|
data/.github/workflows/dummy.yml
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
name: Dummy specs
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
test:
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
|
9
9
|
steps:
|
10
|
-
- uses: actions/checkout@
|
10
|
+
- uses: actions/checkout@v4
|
11
|
+
with:
|
12
|
+
persist-credentials: false
|
11
13
|
- uses: ruby/setup-ruby@v1
|
12
14
|
with:
|
13
15
|
ruby-version: '3.1.2'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
name: Generator specs
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
test:
|
@@ -28,7 +28,9 @@ jobs:
|
|
28
28
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
29
29
|
|
30
30
|
steps:
|
31
|
-
- uses: actions/checkout@
|
31
|
+
- uses: actions/checkout@v4
|
32
|
+
with:
|
33
|
+
persist-credentials: false
|
32
34
|
- uses: ruby/setup-ruby@v1
|
33
35
|
with:
|
34
36
|
ruby-version: ${{ matrix.ruby }}
|
data/.github/workflows/jest.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
name: Jest specs
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
jest:
|
@@ -13,9 +13,11 @@ jobs:
|
|
13
13
|
runs-on: ${{ matrix.os }}
|
14
14
|
|
15
15
|
steps:
|
16
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
with:
|
18
|
+
persist-credentials: false
|
17
19
|
- name: Use Node.js ${{ matrix.node }}
|
18
|
-
uses: actions/setup-node@
|
20
|
+
uses: actions/setup-node@v3
|
19
21
|
with:
|
20
22
|
node-version: ${{ matrix.node }}
|
21
23
|
cache: yarn
|
@@ -1,6 +1,6 @@
|
|
1
1
|
name: JS lint
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
lint:
|
@@ -13,9 +13,11 @@ jobs:
|
|
13
13
|
runs-on: ${{ matrix.os }}
|
14
14
|
|
15
15
|
steps:
|
16
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
with:
|
18
|
+
persist-credentials: false
|
17
19
|
- name: Use Node.js ${{ matrix.node }}
|
18
|
-
uses: actions/setup-node@
|
20
|
+
uses: actions/setup-node@v3
|
19
21
|
with:
|
20
22
|
node-version: ${{ matrix.node }}
|
21
23
|
cache: yarn
|
@@ -1,6 +1,6 @@
|
|
1
1
|
name: Rubocop
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
rubocop:
|
@@ -12,7 +12,9 @@ jobs:
|
|
12
12
|
ruby: ['2.7', '3.0']
|
13
13
|
|
14
14
|
steps:
|
15
|
-
- uses: actions/checkout@
|
15
|
+
- uses: actions/checkout@v4
|
16
|
+
with:
|
17
|
+
persist-credentials: false
|
16
18
|
- uses: ruby/setup-ruby@v1
|
17
19
|
with:
|
18
20
|
ruby-version: ${{ matrix.ruby }}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
name: Ruby specs - Backward compatibility
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
test:
|
@@ -15,7 +15,7 @@ jobs:
|
|
15
15
|
- gemfiles/Gemfile-rails.6.1.x
|
16
16
|
- gemfiles/Gemfile-rails.7.0.x
|
17
17
|
# Uncomment the following line only to ensure compatibility with the
|
18
|
-
#
|
18
|
+
# upcoming Rails versions, maybe before a release.
|
19
19
|
#- gemfiles/Gemfile-rails-edge
|
20
20
|
exclude:
|
21
21
|
- ruby: 2.6
|
@@ -29,7 +29,9 @@ jobs:
|
|
29
29
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
30
30
|
|
31
31
|
steps:
|
32
|
-
- uses: actions/checkout@
|
32
|
+
- uses: actions/checkout@v4
|
33
|
+
with:
|
34
|
+
persist-credentials: false
|
33
35
|
- uses: ruby/setup-ruby@v1
|
34
36
|
with:
|
35
37
|
ruby-version: ${{ matrix.ruby }}
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
name: Ruby specs
|
2
2
|
|
3
|
-
on: [push]
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
test:
|
@@ -29,11 +29,13 @@ jobs:
|
|
29
29
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
30
30
|
|
31
31
|
steps:
|
32
|
-
- uses: actions/checkout@
|
32
|
+
- uses: actions/checkout@v4
|
33
|
+
with:
|
34
|
+
persist-credentials: false
|
33
35
|
- uses: ruby/setup-ruby@v1
|
34
36
|
with:
|
35
37
|
ruby-version: ${{ matrix.ruby }}
|
36
38
|
bundler-cache: true
|
37
39
|
|
38
40
|
- name: Ruby specs
|
39
|
-
run: bundle exec rake run_spec:
|
41
|
+
run: bundle exec rake run_spec:gem
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,18 @@ Changes since last non-beta release.
|
|
9
9
|
|
10
10
|
_Please add entries here for your pull requests that are not yet released._
|
11
11
|
|
12
|
+
### Added
|
13
|
+
- Support passing custom webpack config directly to `generateWebpackConfig` for merging [PR 343](https://github.com/shakacode/shakapacker/pull/343) by [G-Rath](https://github.com/g-rath)
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- Use `NODE_OPTIONS` to enable Node-specific debugging flags [PR 350](https://github.com/shakacode/shakapacker/pull/350)
|
17
|
+
- Add the boilplate `application.js` into `packs/` [PR 363](https://github.com/shakacode/shakapacker/pull/363)
|
18
|
+
|
19
|
+
## [v7.0.3] - July 7, 2023
|
20
|
+
### Fixed
|
21
|
+
- Fixed commands execution for projects with space in absolute path [PR 322](https://github.com/shakacode/shakapacker/pull/322) by [kukicola](https://github.com/kukicola).
|
22
|
+
|
23
|
+
## [v7.0.2] - July 3, 2023
|
12
24
|
### Fixed
|
13
25
|
- Fixed creation of assets:precompile if it is missing [PR 325](https://github.com/shakacode/shakapacker/pull/325) by [ahangarha](https://github.com/ahangarha).
|
14
26
|
|
@@ -262,7 +274,9 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
262
274
|
## v5.4.3 and prior changes from rails/webpacker
|
263
275
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
264
276
|
|
265
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v7.0.
|
277
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v7.0.3...master
|
278
|
+
[v7.0.3]: https://github.com/shakacode/shakapacker/compare/v7.0.2...v7.0.3
|
279
|
+
[v7.0.2]: https://github.com/shakacode/shakapacker/compare/v7.0.1...v7.0.2
|
266
280
|
[v7.0.1]: https://github.com/shakacode/shakapacker/compare/v7.0.0...v7.0.1
|
267
281
|
[v7.0.0]: https://github.com/shakacode/shakapacker/compare/v6.6.0...v7.0.0
|
268
282
|
[v6.6.0]: https://github.com/shakacode/shakapacker/compare/v6.5.6...v6.6.0
|
data/CONTRIBUTING.md
CHANGED
@@ -10,7 +10,7 @@ Thank you for your interest in contributing to Shakapacker! We welcome all contr
|
|
10
10
|
- [Testing the generator](#testing-the-generator)
|
11
11
|
|
12
12
|
## Reporting Issues
|
13
|
-
If you encounter any issues with the project, please first check the
|
13
|
+
If you encounter any issues with the project, please first check the existing issues (including closed ones). If the issues is not reported before, please opening an issue on our GitHub repository. Please provide a clear and detailed description of the issue, including steps to reproduce it. Creating a demo repository to demonstrate the issue would be ideal (and in some cases necessary).
|
14
14
|
|
15
15
|
If looking to contribute to the project by fixing existing issues, we recommend looking at issues, particularly with the "[help wanted](https://github.com/shakacode/shakapacker/issues?q=is%3Aissue+label%3A%22help+wanted%22)" label.
|
16
16
|
|
@@ -41,7 +41,7 @@ We welcome pull requests that fix bugs, add new features, or improve existing on
|
|
41
41
|
# In Rails app for testing
|
42
42
|
yalc link shakapacker
|
43
43
|
|
44
|
-
# After every
|
44
|
+
# After every change in shakapacker, run the following in Shakapacker directory
|
45
45
|
yalc push # or yalc publish --push
|
46
46
|
```
|
47
47
|
3. Run the following commands to set up the development environment.
|
@@ -101,7 +101,7 @@ bundle exec rake run_spec:gem
|
|
101
101
|
```
|
102
102
|
|
103
103
|
#### 4.4 Run only Shakapacker gem specs for backward compatibility
|
104
|
-
These specs are to check
|
104
|
+
These specs are to check Shakapacker v7 backward compatibility with v6.x
|
105
105
|
|
106
106
|
```
|
107
107
|
bundle exec rake run_spec:gem_bc
|
@@ -125,4 +125,3 @@ To ensure that your installer works as expected, either you can run `bundle exec
|
|
125
125
|
3. Run `bundle exec rails shakapacker:install` to confirm that you got the right changes.
|
126
126
|
|
127
127
|
**Note:** Ensure that you use bundle exec otherwise the installed shakapacker gem will run and not the one you are working on.
|
128
|
-
|
data/README.md
CHANGED
@@ -15,13 +15,13 @@ _Official, actively maintained successor to [rails/webpacker](https://github.com
|
|
15
15
|
[![Gem](https://img.shields.io/gem/v/shakapacker.svg)](https://rubygems.org/gems/shakapacker)
|
16
16
|
[![npm version](https://badge.fury.io/js/shakapacker.svg)](https://badge.fury.io/js/shakapacker)
|
17
17
|
|
18
|
-
|
18
|
+
Shakapacker makes it easy to use the JavaScript pre-processor and bundler [Webpack v5+](https://webpack.js.org/)
|
19
19
|
to manage frontend JavaScript in Rails. It can coexist with the asset pipeline,
|
20
20
|
leaving Webpack responsible solely for frontend JavaScript, or can be used exclusively, making it also responsible for images, fonts, and CSS.
|
21
21
|
|
22
22
|
Check out 6.1.1+ for [SWC](https://swc.rs/) and [esbuild-loader](https://github.com/privatenumber/esbuild-loader) support! They are faster than Babel!
|
23
23
|
|
24
|
-
See a comparison of [Shakapacker with jsbundling-rails](https://github.com/rails/jsbundling-rails/blob/main/docs/comparison_with_webpacker.md). For
|
24
|
+
See a comparison of [Shakapacker with jsbundling-rails](https://github.com/rails/jsbundling-rails/blob/main/docs/comparison_with_webpacker.md). For an in-depth discussion of choosing between `shakapacker` and `jsbundling-rails`, see the discussion [Webpacker alternatives - which path should we go to? #8783](https://github.com/decidim/decidim/discussions/8783) and the resulting PR [Switch away from Webpacker to Shakapacker #10389](https://github.com/decidim/decidim/pull/10389).
|
25
25
|
|
26
26
|
For discussions, see our [Slack Channel](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
|
27
27
|
|
@@ -214,7 +214,7 @@ public/packs # webpack output
|
|
214
214
|
|
215
215
|
Webpack intelligently includes only necessary files. In this example, the file `packs/application.js` would reference `../src/my_component.js`
|
216
216
|
|
217
|
-
`nested_entries` allows you to have webpack entry points nested in subdirectories. This defaults to
|
217
|
+
`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.
|
218
218
|
|
219
219
|
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).
|
220
220
|
|
@@ -465,26 +465,40 @@ First, you don't _need_ to use Shakapacker's webpack configuration. However, the
|
|
465
465
|
|
466
466
|
1. Your output files go to the right directory
|
467
467
|
2. Your output includes a manifest, via package [`webpack-assets-manifest`](https://github.com/webdeveric/webpack-assets-manifest) that maps output names (your 'packs') to the fingerprinted versions, including bundle-splitting dependencies. That's the main secret sauce of Shakapacker!
|
468
|
+
|
469
|
+
The webpack configuration used by Shakapacker lives in `config/webpack/webpack.config.js`; this makes it easy to customize the configuration beyond what's available in `config/shakapacker.yml` by giving you complete control of the final configuration. By default, this file exports the result of `generateWebpackConfig` which handles generating a webpack configuration based on `config/shakapacker.yml`.
|
468
470
|
|
469
|
-
The
|
471
|
+
The easiest way to modify this config is to pass your desired customizations to `generateWebpackConfig` which will use [webpack-merge](https://github.com/survivejs/webpack-merge) to merge them with the configuration generated from `config/shakapacker.yml`:
|
470
472
|
|
471
473
|
```js
|
472
|
-
//
|
473
|
-
|
474
|
+
// config/webpack/webpack.config.js
|
475
|
+
const { generateWebpackConfig } = require('shakapacker')
|
476
|
+
|
477
|
+
const options = {
|
478
|
+
resolve: {
|
479
|
+
extensions: ['.css', '.ts', '.tsx']
|
480
|
+
}
|
481
|
+
}
|
482
|
+
|
483
|
+
// This results in a new object copied from the mutable global
|
484
|
+
module.exports = generateWebpackConfig(options)
|
485
|
+
```
|
486
|
+
|
487
|
+
The `shakapacker` package also exports the `merge` function from [webpack-merge](https://github.com/survivejs/webpack-merge) to make it easier to do more advanced customizations:
|
488
|
+
|
489
|
+
```js
|
490
|
+
// config/webpack/webpack.config.js
|
474
491
|
const { generateWebpackConfig, merge } = require('shakapacker')
|
475
492
|
|
476
|
-
const
|
493
|
+
const webpackConfig = generateWebpackConfig()
|
477
494
|
|
478
495
|
const options = {
|
479
496
|
resolve: {
|
480
|
-
|
497
|
+
extensions: ['.css', '.ts', '.tsx']
|
481
498
|
}
|
482
499
|
}
|
483
500
|
|
484
|
-
|
485
|
-
// If you want to use this object for client and server rendering configurations,
|
486
|
-
// having a new object is essential.
|
487
|
-
module.exports = merge({}, baseWebpackConfig, options)
|
501
|
+
module.exports = merge(options, webpackConfig)
|
488
502
|
```
|
489
503
|
|
490
504
|
This example is based on [an example project](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/webpack.config.js)
|
@@ -513,12 +527,11 @@ Then `require` this file in your `config/webpack/webpack.config.js`:
|
|
513
527
|
```js
|
514
528
|
// config/webpack/webpack.config.js
|
515
529
|
// use the new NPM package name, `shakapacker`.
|
516
|
-
const { generateWebpackConfig
|
530
|
+
const { generateWebpackConfig } = require('shakapacker')
|
517
531
|
|
518
|
-
const webpackConfig = generateWebpackConfig()
|
519
532
|
const customConfig = require('./custom')
|
520
533
|
|
521
|
-
module.exports =
|
534
|
+
module.exports = generateWebpackConfig(customConfig)
|
522
535
|
```
|
523
536
|
|
524
537
|
If you need access to configs within Shakapacker's configuration, you can import them like so:
|
@@ -616,12 +629,10 @@ Then modify the webpack config to use it as a plugin:
|
|
616
629
|
|
617
630
|
```js
|
618
631
|
// config/webpack/webpack.config.js
|
619
|
-
const { generateWebpackConfig
|
620
|
-
|
621
|
-
const webpackConfig = generateWebpackConfig()
|
632
|
+
const { generateWebpackConfig } = require("shakapacker");
|
622
633
|
const ForkTSCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
623
634
|
|
624
|
-
module.exports =
|
635
|
+
module.exports = generateWebpackConfig({
|
625
636
|
plugins: [new ForkTSCheckerWebpackPlugin()],
|
626
637
|
});
|
627
638
|
```
|
@@ -638,9 +649,7 @@ Optionally, add the `CSS` extension to webpack config for easy resolution.
|
|
638
649
|
|
639
650
|
```js
|
640
651
|
// config/webpack/webpack.config.js
|
641
|
-
const { generateWebpackConfig
|
642
|
-
|
643
|
-
const webpackConfig = generateWebpackConfig()
|
652
|
+
const { generateWebpackConfig } = require('shakapacker')
|
644
653
|
|
645
654
|
const customConfig = {
|
646
655
|
resolve: {
|
@@ -648,7 +657,7 @@ const customConfig = {
|
|
648
657
|
}
|
649
658
|
}
|
650
659
|
|
651
|
-
module.exports =
|
660
|
+
module.exports = generateWebpackConfig(customConfig)
|
652
661
|
```
|
653
662
|
|
654
663
|
To enable `PostCSS`, `Sass` or `Less` support, add `CSS` support first and
|
@@ -893,6 +902,11 @@ The following companies support our Open Source projects, and ShakaCode uses the
|
|
893
902
|
<img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
|
894
903
|
</picture>
|
895
904
|
</a>
|
905
|
+
<a href="https://controlplane.com">
|
906
|
+
<picture>
|
907
|
+
<img alt="Control Plane" src="https://github.com/shakacode/.github/assets/20628911/90babd87-62c4-4de3-baa4-3d78ef4bec25" height="120px">
|
908
|
+
</picture>
|
909
|
+
</a>
|
896
910
|
<br />
|
897
911
|
<a href="https://www.browserstack.com">
|
898
912
|
<picture>
|
data/docs/deployment.md
CHANGED
@@ -94,7 +94,7 @@ If you are using a CDN setup, Shakapacker does NOT use the `ASSET_HOST` environm
|
|
94
94
|
|
95
95
|
### Assets compiling on every deployment even if JavaScript and CSS files are not changed
|
96
96
|
|
97
|
-
Make sure you have your public
|
97
|
+
Make sure you have your public output path (default `public/packs`), the shakapacker cache path (default `tmp/shakapacker`) and `node_modules` in `:linked_dirs`
|
98
98
|
|
99
99
|
```ruby
|
100
100
|
append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/shakapacker", "public/packs", ".bundle", "node_modules"
|
data/docs/react.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# React Integration
|
2
2
|
|
3
|
-
These steps describe
|
3
|
+
These steps describe creating a Rails/React app, using Shakapacker as the bundler.
|
4
4
|
|
5
5
|
Before starting, ensure that you have Yarn installed, for example:
|
6
6
|
|
@@ -45,7 +45,7 @@ And that's it. You can now create a React app using `app/javascript/application.
|
|
45
45
|
|
46
46
|
With HMR enabled, Shakapacker will automatically update only that part of the page that changed when it detects changes in your project files. This has the nice advantage of preserving your app’s state.
|
47
47
|
|
48
|
-
To enable HMR in a React app, proceed as follows
|
48
|
+
To enable HMR in a React app, proceed as follows:
|
49
49
|
|
50
50
|
In `config/shakapacker.yml` set `hmr` is set to `true`.
|
51
51
|
|
@@ -262,7 +262,7 @@ module.exports = function (api) {
|
|
262
262
|
}
|
263
263
|
```
|
264
264
|
|
265
|
-
9. Start the Rails server and the
|
265
|
+
9. Start the Rails server and the `shakapacker-dev-server` in separate console windows:
|
266
266
|
```shell
|
267
267
|
rails s
|
268
268
|
./bin/shakapacker-dev-server
|
@@ -272,4 +272,4 @@ rails s
|
|
272
272
|
|
273
273
|
11. Edit either the React component at `app/javascript/App.js` or the CSS file at `app/javascript/App.css` and observe the HMR goodness.
|
274
274
|
|
275
|
-
Note that HMR will not work if you edit `app/javascript/application.js` and
|
275
|
+
Note that HMR will not work if you edit `app/javascript/application.js` and experience a full refresh with a warning in the console. For more info on this, see here: https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/177
|
data/docs/troubleshooting.md
CHANGED
@@ -150,11 +150,9 @@ To silent these warnings, please update `config/webpack/webpack.config.js`:
|
|
150
150
|
```js
|
151
151
|
const webpack = require('webpack')
|
152
152
|
const { resolve } = require('path')
|
153
|
-
const { generateWebpackConfig
|
153
|
+
const { generateWebpackConfig } = require('shakapacker')
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
module.exports = merge(webpackConfig, {
|
155
|
+
module.exports = generateWebpackConfig({
|
158
156
|
plugins: [
|
159
157
|
new webpack.ContextReplacementPlugin(
|
160
158
|
/angular(\\|\/)core(\\|\/)(@angular|esm5)/,
|
@@ -201,11 +199,9 @@ Instead do:
|
|
201
199
|
// config/webpack/webpack.config.js
|
202
200
|
|
203
201
|
const webpack = require('webpack')
|
204
|
-
const { generateWebpackConfig
|
205
|
-
|
206
|
-
const webpackConfig = generateWebpackConfig();
|
202
|
+
const { generateWebpackConfig } = require('shakapacker')
|
207
203
|
|
208
|
-
module.exports =
|
204
|
+
module.exports = generateWebpackConfig({
|
209
205
|
plugins: [
|
210
206
|
new webpack.ProvidePlugin({
|
211
207
|
$: 'jquery',
|
@@ -8,7 +8,7 @@ If you face any issues, please report them at https://github.com/shakacode/shaka
|
|
8
8
|
|
9
9
|
[esbuild](https://esbuild.github.io/) is a Go-based bundler tool that can offer [significant improvement](https://esbuild.github.io/faq/#benchmark-details) over other similar tools.
|
10
10
|
|
11
|
-
While esbuild is a complete bundler, through the usage of [esbuild-loader](https://github.com/privatenumber/esbuild-loader), you can still leverage esbuild's speedy transpilation and
|
11
|
+
While esbuild is a complete bundler, through the usage of [esbuild-loader](https://github.com/privatenumber/esbuild-loader), you can still leverage esbuild's speedy transpilation and minification in your Webpack-based configs.
|
12
12
|
|
13
13
|
Please note, that unlike Babel or SWC loader, esbuild-loader has got no support for things like:
|
14
14
|
- React Hot Module reload
|
@@ -59,11 +59,9 @@ o do so, you need to modify your webpack configuration and use `ESBuildMinifyPlu
|
|
59
59
|
Example:
|
60
60
|
|
61
61
|
```js
|
62
|
-
const { generateWebpackConfig
|
62
|
+
const { generateWebpackConfig } = require('shakapacker')
|
63
63
|
const { ESBuildMinifyPlugin } = require('esbuild-loader')
|
64
64
|
|
65
|
-
const baseWebpackConfig = generateWebpackConfig()
|
66
|
-
|
67
65
|
const options = {
|
68
66
|
optimization: {
|
69
67
|
minimizer: [
|
@@ -74,7 +72,7 @@ const options = {
|
|
74
72
|
}
|
75
73
|
}
|
76
74
|
|
77
|
-
module.exports =
|
75
|
+
module.exports = generateWebpackConfig(options)
|
78
76
|
```
|
79
77
|
|
80
78
|
For more details, see instructions at https://github.com/shakacode/shakapacker#webpack-configuration and https://github.com/privatenumber/esbuild-loader#js-minification-eg-terser.
|
data/docs/v6_upgrade.md
CHANGED
@@ -97,7 +97,7 @@ _If you're on webpacker v5, follow [how to upgrade to webpacker v6.0.0.rc.6 from
|
|
97
97
|
```
|
98
98
|
If you prefer this configuration, then you will move your `app/javascript/packs/*` (including `application.js`) to `app/javascript/` and update the configuration file.
|
99
99
|
|
100
|
-
Note, moving your files is optional, as you can
|
100
|
+
Note, moving your files is optional, as you can still keep your entries in a separate directory, called something like `packs`, or `entries`. This directory is defined with the `source_path`.
|
101
101
|
|
102
102
|
1. Update `webpack-dev-server` to the current version, greater than 4.2, updating `package.json`.
|
103
103
|
|
data/docs/v7_upgrade.md
CHANGED
@@ -35,7 +35,7 @@ When generating file paths for static assets, a top-level directory will no long
|
|
35
35
|
## The `webpackConfig` property is changed
|
36
36
|
|
37
37
|
The `webpackConfig` property in the `shakapacker` module has been changed. The shakapacker module has two options:
|
38
|
-
1. `
|
38
|
+
1. `generateWebpackConfig`: a function that returns a new webpack configuration object, which ensures that any modifications made to it will not affect any other usage of the webpack configuration.
|
39
39
|
2. `globalMutableWebpackConfig`: if a project still desires the old mutable object. You can rename your imports of `webpackConfig` with `globalMutableWebpackConfig`.
|
40
40
|
|
41
41
|
## Example Upgrade
|
@@ -45,7 +45,7 @@ If you started with:
|
|
45
45
|
const { webpackConfig } = require('shakapacker')
|
46
46
|
```
|
47
47
|
|
48
|
-
|
48
|
+
Switch to:
|
49
49
|
|
50
50
|
```js
|
51
51
|
const { generateWebpackConfig } = require('shakapacker')
|
data/lib/install/template.rb
CHANGED
@@ -14,8 +14,8 @@ if Dir.exist?(Shakapacker.config.source_path)
|
|
14
14
|
say "The packs app source directory already exists"
|
15
15
|
else
|
16
16
|
say "Creating packs app source directory"
|
17
|
-
empty_directory "app/javascript"
|
18
|
-
copy_file "#{__dir__}/application.js", "app/javascript/application.js"
|
17
|
+
empty_directory "app/javascript/packs"
|
18
|
+
copy_file "#{__dir__}/application.js", "app/javascript/packs/application.js"
|
19
19
|
end
|
20
20
|
|
21
21
|
apply "#{__dir__}/binstubs.rb"
|
data/lib/shakapacker/compiler.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "thor"
|
2
2
|
|
3
3
|
module Shakapacker
|
4
|
-
DEPRECATION_GUIDE_URL = "https://github.com/shakacode/shakapacker/docs/v7_upgrade.md"
|
4
|
+
DEPRECATION_GUIDE_URL = "https://github.com/shakacode/shakapacker/blob/master/docs/v7_upgrade.md"
|
5
5
|
DEPRECATION_MESSAGE = <<~MSG
|
6
6
|
DEPRECATION NOTICE:
|
7
7
|
|
@@ -66,6 +66,7 @@ module Shakapacker
|
|
66
66
|
env = Shakapacker::Compiler.env
|
67
67
|
env["SHAKAPACKER_CONFIG"] = @shakapacker_config
|
68
68
|
env["WEBPACK_SERVE"] = "true"
|
69
|
+
env["NODE_OPTIONS"] = ENV["NODE_OPTIONS"] || ""
|
69
70
|
|
70
71
|
cmd = if node_modules_bin_exist?
|
71
72
|
["#{@node_modules_bin_path}/webpack", "serve"]
|
@@ -83,7 +84,7 @@ module Shakapacker
|
|
83
84
|
end
|
84
85
|
|
85
86
|
if @argv.delete("--debug-shakapacker") || @argv.delete("--debug-webpacker")
|
86
|
-
|
87
|
+
env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --inspect-brk --trace-warnings"
|
87
88
|
end
|
88
89
|
|
89
90
|
cmd += ["--config", @webpack_config]
|
@@ -29,7 +29,7 @@ module Shakapacker
|
|
29
29
|
|
30
30
|
# Executes a string or an array of strings in a shell in the given directory in an unbundled environment
|
31
31
|
def self.sh_in_dir(dir, *shell_commands)
|
32
|
-
shell_commands.flatten.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
|
32
|
+
shell_commands.flatten.each { |shell_command| sh %(cd '#{dir}' && #{shell_command.strip}) }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/shakapacker/version.rb
CHANGED
@@ -91,7 +91,7 @@ module Shakapacker
|
|
91
91
|
attr_reader :package_json
|
92
92
|
|
93
93
|
def self.build
|
94
|
-
new(package_json_path, yarn_lock_path, package_lock_path)
|
94
|
+
new(package_json_path, yarn_lock_path, package_lock_path, pnpm_lock_path)
|
95
95
|
end
|
96
96
|
|
97
97
|
def self.package_json_path
|
@@ -106,10 +106,15 @@ module Shakapacker
|
|
106
106
|
Rails.root.join("package-lock.json")
|
107
107
|
end
|
108
108
|
|
109
|
-
def
|
109
|
+
def self.pnpm_lock_path
|
110
|
+
Rails.root.join("pnpm-lock.yaml")
|
111
|
+
end
|
112
|
+
|
113
|
+
def initialize(package_json, yarn_lock, package_lock, pnpm_lock)
|
110
114
|
@package_json = package_json
|
111
115
|
@yarn_lock = yarn_lock
|
112
116
|
@package_lock = package_lock
|
117
|
+
@pnpm_lock = pnpm_lock
|
113
118
|
end
|
114
119
|
|
115
120
|
def raw
|
@@ -170,6 +175,12 @@ module Shakapacker
|
|
170
175
|
return version unless version.nil?
|
171
176
|
end
|
172
177
|
|
178
|
+
if File.exist?(@pnpm_lock)
|
179
|
+
version = from_pnpm_lock
|
180
|
+
|
181
|
+
return version unless version.nil?
|
182
|
+
end
|
183
|
+
|
173
184
|
parsed_package_contents = JSON.parse(package_json_contents)
|
174
185
|
parsed_package_contents.dig("dependencies", "shakapacker").to_s
|
175
186
|
end
|
@@ -210,6 +221,28 @@ module Shakapacker
|
|
210
221
|
|
211
222
|
version
|
212
223
|
end
|
224
|
+
|
225
|
+
def from_pnpm_lock
|
226
|
+
require "yaml"
|
227
|
+
|
228
|
+
content = YAML.load_file(@pnpm_lock)
|
229
|
+
|
230
|
+
content.fetch("packages", {}).each do |key, value|
|
231
|
+
return value["version"] if value["name"] == "shakapacker"
|
232
|
+
|
233
|
+
parts = key.split("/")
|
234
|
+
|
235
|
+
return parts[2] if parts[1] == "shakapacker"
|
236
|
+
next unless parts[1].start_with?("shakapacker@")
|
237
|
+
|
238
|
+
_, version = parts[1].split("@")
|
239
|
+
|
240
|
+
return version[0, version.index("(")] if version.include?("(")
|
241
|
+
return version
|
242
|
+
end
|
243
|
+
|
244
|
+
nil
|
245
|
+
end
|
213
246
|
end
|
214
247
|
end
|
215
248
|
end
|