shakapacker 7.0.2 → 7.0.3
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 +1 -1
- data/.github/workflows/generator.yml +1 -1
- data/.github/workflows/jest.yml +1 -1
- data/.github/workflows/js-lint.yml +1 -1
- data/.github/workflows/rubocop.yml +1 -1
- data/.github/workflows/ruby-backward-compatibility.yml +2 -2
- data/.github/workflows/ruby.yml +1 -1
- data/CHANGELOG.md +8 -1
- data/CONTRIBUTING.md +3 -4
- data/README.md +8 -3
- data/docs/deployment.md +1 -1
- data/docs/react.md +4 -4
- data/docs/using_esbuild_loader.md +1 -1
- data/docs/v6_upgrade.md +1 -1
- data/docs/v7_upgrade.md +2 -2
- data/lib/shakapacker/compiler.rb +1 -1
- data/lib/shakapacker/utils/misc.rb +1 -1
- data/lib/shakapacker/version.rb +1 -1
- 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/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.json +12 -1
- data/rakelib/release.rake +1 -1
- data/spec/backward_compatibility_specs/compiler_spec.rb +2 -2
- data/spec/backward_compatibility_specs/configuration_spec.rb +4 -4
- data/spec/generator_specs/generator_spec.rb +5 -5
- data/spec/shakapacker/compiler_spec.rb +2 -2
- data/spec/shakapacker/configuration_spec.rb +4 -4
- data/spec/shakapacker/rake_tasks_spec.rb +1 -1
- data/spec/shakapacker/version_checker_spec.rb +4 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9451e388d4f6c2419456201c10b56e5f24ef5a1b6abaf82fb950187f16c4cbb
|
4
|
+
data.tar.gz: 9082cdaec1dffb060c1a903a3589373170741d0744b65c41d6d901669b77d614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc8eb8a8b9b52b4a1a9c2a1bcb4ae6e24f59484ea97f660e030a5660b5c6b4d8b077f8e784fbf6f1bf032e5d89b0c26b7d5b421b8c2692747aafb9820e46971b
|
7
|
+
data.tar.gz: c3a7d20636ee49637516df81a72813f34f82dceb88ecd1dbc276071f6d44ce756326094d9b31feaf93d8d83325687af37eaead127b3f00e8cf25e9d65764be6f
|
data/.github/workflows/dummy.yml
CHANGED
data/.github/workflows/jest.yml
CHANGED
@@ -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
|
data/.github/workflows/ruby.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,11 @@ 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
|
+
## [v7.0.3] - July 7, 2023
|
13
|
+
### Fixed
|
14
|
+
- 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).
|
15
|
+
|
16
|
+
## [v7.0.2] - July 3, 2023
|
12
17
|
### Fixed
|
13
18
|
- 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
19
|
|
@@ -262,7 +267,9 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
262
267
|
## v5.4.3 and prior changes from rails/webpacker
|
263
268
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
264
269
|
|
265
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v7.0.
|
270
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v7.0.3...master
|
271
|
+
[v7.0.3]: https://github.com/shakacode/shakapacker/compare/v7.0.2...v7.0.3
|
272
|
+
[v7.0.2]: https://github.com/shakacode/shakapacker/compare/v7.0.1...v7.0.2
|
266
273
|
[v7.0.1]: https://github.com/shakacode/shakapacker/compare/v7.0.0...v7.0.1
|
267
274
|
[v7.0.0]: https://github.com/shakacode/shakapacker/compare/v6.6.0...v7.0.0
|
268
275
|
[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
|
|
@@ -893,6 +893,11 @@ The following companies support our Open Source projects, and ShakaCode uses the
|
|
893
893
|
<img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
|
894
894
|
</picture>
|
895
895
|
</a>
|
896
|
+
<a href="https://controlplane.com">
|
897
|
+
<picture>
|
898
|
+
<img alt="Control Plane" src="https://github.com/shakacode/.github/assets/20628911/90babd87-62c4-4de3-baa4-3d78ef4bec25" height="120px">
|
899
|
+
</picture>
|
900
|
+
</a>
|
896
901
|
<br />
|
897
902
|
<a href="https://www.browserstack.com">
|
898
903
|
<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
|
@@ -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
|
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/shakapacker/compiler.rb
CHANGED
@@ -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
@@ -7,9 +7,9 @@ namespace :shakapacker do
|
|
7
7
|
prefix = task.name.split(/#|shakapacker:binstubs/).first
|
8
8
|
|
9
9
|
if Rails::VERSION::MAJOR >= 5
|
10
|
-
exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{binstubs_template_path}'"
|
10
|
+
exec "#{RbConfig.ruby} '#{bin_path}/rails' #{prefix}app:template LOCATION='#{binstubs_template_path}'"
|
11
11
|
else
|
12
|
-
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{binstubs_template_path}'"
|
12
|
+
exec "#{RbConfig.ruby} '#{bin_path}/rake' #{prefix}rails:template LOCATION='#{binstubs_template_path}'"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,12 +1,17 @@
|
|
1
1
|
namespace :shakapacker do
|
2
2
|
desc "Verifies that bin/shakapacker is present"
|
3
3
|
task :check_binstubs do
|
4
|
-
|
5
|
-
|
4
|
+
verify_file_existence("bin/shakapacker", "bin/webpacker")
|
5
|
+
verify_file_existence("bin/shakapacker-dev-server", "bin/webpacker-dev-server")
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
def verify_file_existance(main_file, alternative_file)
|
10
|
+
puts "verify_file_existance is deprecated - use verify_file_existence instead"
|
11
|
+
verify_file_existence(main_file, alternative_file)
|
12
|
+
end
|
13
|
+
|
14
|
+
def verify_file_existence(main_file, alternative_file)
|
10
15
|
unless File.exist?(Rails.root.join(main_file))
|
11
16
|
if File.exist?(Rails.root.join(alternative_file))
|
12
17
|
Shakapacker.puts_deprecation_message(
|
@@ -9,9 +9,9 @@ namespace :shakapacker do
|
|
9
9
|
prefix = task.name.split(/#|shakapacker:install/).first
|
10
10
|
|
11
11
|
if Rails::VERSION::MAJOR >= 5
|
12
|
-
exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{install_template_path}'"
|
12
|
+
exec "#{RbConfig.ruby} '#{bin_path}/rails' #{prefix}app:template LOCATION='#{install_template_path}'"
|
13
13
|
else
|
14
|
-
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{install_template_path}'"
|
14
|
+
exec "#{RbConfig.ruby} '#{bin_path}/rake' #{prefix}rails:template LOCATION='#{install_template_path}'"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* global test expect, describe, afterAll, beforeEach */
|
2
2
|
|
3
|
-
// environment.js expects to find config/
|
3
|
+
// environment.js expects to find config/webpacker.yml and resolved modules from
|
4
4
|
// the root of a Rails project
|
5
5
|
|
6
6
|
const { resetEnv, chdirWebpackerTestApp } = require('../../utils/helpers')
|
@@ -16,10 +16,10 @@ describe('Development specific config', () => {
|
|
16
16
|
test('sets filename to use contentHash', () => {
|
17
17
|
const config = require("../../config");
|
18
18
|
config.useContentHash = true
|
19
|
-
const
|
19
|
+
const environmentConfig = require('../development')
|
20
20
|
|
21
|
-
expect(
|
22
|
-
expect(
|
21
|
+
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
22
|
+
expect(environmentConfig.output.chunkFilename).toEqual(
|
23
23
|
'js/[name]-[contenthash].chunk.js'
|
24
24
|
)
|
25
25
|
})
|
@@ -29,10 +29,10 @@ describe('Development specific config', () => {
|
|
29
29
|
test('sets filename without using contentHash', () => {
|
30
30
|
const config = require("../../config");
|
31
31
|
config.useContentHash = false
|
32
|
-
const
|
32
|
+
const environmentConfig = require('../development')
|
33
33
|
|
34
|
-
expect(
|
35
|
-
expect(
|
34
|
+
expect(environmentConfig.output.filename).toEqual('js/[name].js')
|
35
|
+
expect(environmentConfig.output.chunkFilename).toEqual(
|
36
36
|
'js/[name].chunk.js'
|
37
37
|
)
|
38
38
|
})
|
@@ -42,10 +42,10 @@ describe('Development specific config', () => {
|
|
42
42
|
test('sets filename without using contentHash', () => {
|
43
43
|
const config = require("../../config");
|
44
44
|
delete config.useContentHash
|
45
|
-
const
|
45
|
+
const environmentConfig = require('../development')
|
46
46
|
|
47
|
-
expect(
|
48
|
-
expect(
|
47
|
+
expect(environmentConfig.output.filename).toEqual('js/[name].js')
|
48
|
+
expect(environmentConfig.output.chunkFilename).toEqual(
|
49
49
|
'js/[name].chunk.js'
|
50
50
|
)
|
51
51
|
})
|
@@ -16,10 +16,10 @@ describe('Production specific config', () => {
|
|
16
16
|
test('sets filename to use contentHash', () => {
|
17
17
|
const config = require("../../config");
|
18
18
|
config.useContentHash = true
|
19
|
-
const
|
19
|
+
const environmentConfig = require('../production')
|
20
20
|
|
21
|
-
expect(
|
22
|
-
expect(
|
21
|
+
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
22
|
+
expect(environmentConfig.output.chunkFilename).toEqual(
|
23
23
|
'js/[name]-[contenthash].chunk.js'
|
24
24
|
)
|
25
25
|
})
|
@@ -28,7 +28,7 @@ describe('Production specific config', () => {
|
|
28
28
|
const consoleWarnSpy = jest.spyOn(console, 'warn');
|
29
29
|
const config = require("../../config");
|
30
30
|
config.useContentHash = true
|
31
|
-
const
|
31
|
+
const environmentConfig = require('../production')
|
32
32
|
|
33
33
|
expect(consoleWarnSpy).not.toHaveBeenCalledWith(
|
34
34
|
expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/)
|
@@ -42,10 +42,10 @@ describe('Production specific config', () => {
|
|
42
42
|
test('sets filename to use contentHash', () => {
|
43
43
|
const config = require("../../config");
|
44
44
|
config.useContentHash = false
|
45
|
-
const
|
45
|
+
const environmentConfig = require('../production')
|
46
46
|
|
47
|
-
expect(
|
48
|
-
expect(
|
47
|
+
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
48
|
+
expect(environmentConfig.output.chunkFilename).toEqual(
|
49
49
|
'js/[name]-[contenthash].chunk.js'
|
50
50
|
)
|
51
51
|
})
|
@@ -54,7 +54,7 @@ describe('Production specific config', () => {
|
|
54
54
|
const consoleWarnSpy = jest.spyOn(console, 'warn');
|
55
55
|
const config = require("../../config");
|
56
56
|
config.useContentHash = false
|
57
|
-
const
|
57
|
+
const environmentConfig = require('../production')
|
58
58
|
|
59
59
|
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
60
60
|
expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/)
|
@@ -68,10 +68,10 @@ describe('Production specific config', () => {
|
|
68
68
|
test('sets filename to use contentHash', () => {
|
69
69
|
const config = require("../../config");
|
70
70
|
delete config.useContentHash
|
71
|
-
const
|
71
|
+
const environmentConfig = require('../production')
|
72
72
|
|
73
|
-
expect(
|
74
|
-
expect(
|
73
|
+
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
74
|
+
expect(environmentConfig.output.chunkFilename).toEqual(
|
75
75
|
'js/[name]-[contenthash].chunk.js'
|
76
76
|
)
|
77
77
|
})
|
@@ -80,7 +80,7 @@ describe('Production specific config', () => {
|
|
80
80
|
const consoleWarnSpy = jest.spyOn(console, 'warn');
|
81
81
|
const config = require("../../config");
|
82
82
|
delete config.useContentHash
|
83
|
-
const
|
83
|
+
const environmentConfig = require('../production')
|
84
84
|
|
85
85
|
expect(consoleWarnSpy).not.toHaveBeenCalledWith(
|
86
86
|
expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/)
|
data/package/index.d.ts
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
declare module 'shakapacker' {
|
2
|
+
import { Configuration } from 'webpack'
|
3
|
+
|
4
|
+
export interface Config {
|
5
|
+
source_path: string
|
6
|
+
source_entry_path: string
|
7
|
+
nested_entries: boolean
|
8
|
+
css_extract_ignore_order_warnings: boolean
|
9
|
+
public_root_path: string
|
10
|
+
public_output_path: string
|
11
|
+
cache_path: string
|
12
|
+
webpack_compile_output: boolean
|
13
|
+
shakapacker_precompile: boolean
|
14
|
+
additional_paths: string[]
|
15
|
+
cache_manifest: boolean
|
16
|
+
webpack_loader: string
|
17
|
+
ensure_consistent_versioning: boolean
|
18
|
+
compiler_strategy: string
|
19
|
+
useContentHash: boolean
|
20
|
+
compile: boolean,
|
21
|
+
outputPath: string
|
22
|
+
publicPath: string
|
23
|
+
publicPathWithoutCDN: string
|
24
|
+
manifestPath: string
|
25
|
+
}
|
26
|
+
|
27
|
+
export interface Env {
|
28
|
+
railsEnv: string
|
29
|
+
nodeEnv: string
|
30
|
+
isProduction: boolean
|
31
|
+
isDevelopment: boolean
|
32
|
+
runningWebpackDevServer: boolean
|
33
|
+
}
|
34
|
+
|
35
|
+
export const config: Config
|
36
|
+
export const devServer: Record<string, unknown>
|
37
|
+
export function generateWebpackConfig(): Configuration
|
38
|
+
export const globalMutableWebpackConfig: Configuration
|
39
|
+
export const baseConfig: Configuration
|
40
|
+
export const env: Env
|
41
|
+
export const rules: Record<string, unknown>
|
42
|
+
export function moduleExists(packageName: string): boolean
|
43
|
+
export function canProcess<T = unknown>(rule: string, fn: (modulePath: string) => T): T | null
|
44
|
+
export const inliningCss: boolean
|
45
|
+
export * from 'webpack-merge'
|
46
|
+
}
|
47
|
+
|
48
|
+
declare module 'shakapacker/package/babel/preset.js' {
|
49
|
+
import { ConfigAPI, PluginItem, TransformOptions } from '@babel/core'
|
50
|
+
|
51
|
+
interface RequiredTransformOptions {
|
52
|
+
plugins: PluginItem[]
|
53
|
+
presets: PluginItem[]
|
54
|
+
}
|
55
|
+
|
56
|
+
const defaultConfigFunc: (
|
57
|
+
api: ConfigAPI
|
58
|
+
) => TransformOptions & RequiredTransformOptions
|
59
|
+
|
60
|
+
export = defaultConfigFunc
|
61
|
+
}
|
data/package.json
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "7.0.
|
3
|
+
"version": "7.0.3",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"main": "package/index.js",
|
6
|
+
"types": "package/index.d.ts",
|
6
7
|
"files": [
|
7
8
|
"package",
|
8
9
|
"lib/install/config/shakapacker.yml"
|
@@ -12,6 +13,8 @@
|
|
12
13
|
"yarn": ">=1 <4"
|
13
14
|
},
|
14
15
|
"peerDependencies": {
|
16
|
+
"@types/babel__core": "^7.0.0",
|
17
|
+
"@types/webpack": "^5.0.0",
|
15
18
|
"@babel/core": "^7.17.9",
|
16
19
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
17
20
|
"@babel/preset-env": "^7.16.11",
|
@@ -25,6 +28,14 @@
|
|
25
28
|
"webpack-dev-server": "^4.9.0",
|
26
29
|
"webpack-merge": "^5.8.0"
|
27
30
|
},
|
31
|
+
"peerDependenciesMeta": {
|
32
|
+
"@types/babel__core": {
|
33
|
+
"optional": true
|
34
|
+
},
|
35
|
+
"@types/webpack": {
|
36
|
+
"optional": true
|
37
|
+
}
|
38
|
+
},
|
28
39
|
"dependencies": {
|
29
40
|
"glob": "^7.2.0",
|
30
41
|
"js-yaml": "^4.1.0",
|
data/rakelib/release.rake
CHANGED
@@ -25,7 +25,7 @@ Note, accept defaults for npmjs options. Script will pause to get 2FA tokens.
|
|
25
25
|
|
26
26
|
Example: `rake release[2.1.0,false]`")
|
27
27
|
task :create_release, %i[gem_version dry_run] do |_t, args|
|
28
|
-
# Check if there are
|
28
|
+
# Check if there are uncommitted changes
|
29
29
|
Shakapacker::Utils::Misc.uncommitted_changes?(RaisingMessageHandler.new)
|
30
30
|
args_hash = args.to_hash
|
31
31
|
|
@@ -26,7 +26,7 @@ describe "Webpacker::Compiler" do
|
|
26
26
|
allow(Webpacker.compiler).to receive(:strategy).and_return(mocked_strategy)
|
27
27
|
|
28
28
|
status = OpenStruct.new(success?: true)
|
29
|
-
allow(Open3).to receive(:capture3).and_return([:
|
29
|
+
allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status])
|
30
30
|
|
31
31
|
expect(Webpacker.compiler.compile).to be true
|
32
32
|
expect(mocked_strategy).to have_received(:after_compile_hook)
|
@@ -40,7 +40,7 @@ describe "Webpacker::Compiler" do
|
|
40
40
|
allow(Webpacker.compiler).to receive(:strategy).and_return(mocked_strategy)
|
41
41
|
|
42
42
|
status = OpenStruct.new(success?: false)
|
43
|
-
allow(Open3).to receive(:capture3).and_return([:
|
43
|
+
allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status])
|
44
44
|
|
45
45
|
expect(Webpacker.compiler.compile).to be false
|
46
46
|
expect(mocked_strategy).to have_received(:after_compile_hook)
|
@@ -56,7 +56,7 @@ describe "Webpacker::Configuration" do
|
|
56
56
|
expect(config.cache_manifest?).to be true
|
57
57
|
end
|
58
58
|
|
59
|
-
it "returns false in
|
59
|
+
it "returns false in development environment" do
|
60
60
|
with_rails_env("development") do
|
61
61
|
expect(Webpacker.config.cache_manifest?).to be false
|
62
62
|
end
|
@@ -74,13 +74,13 @@ describe "Webpacker::Configuration" do
|
|
74
74
|
expect(config.compile?).to be false
|
75
75
|
end
|
76
76
|
|
77
|
-
it "returns true in
|
77
|
+
it "returns true in development environment" do
|
78
78
|
with_rails_env("development") do
|
79
79
|
expect(Webpacker.config.compile?).to be true
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
it "returns true in test
|
83
|
+
it "returns true in test environment" do
|
84
84
|
with_rails_env("test") do
|
85
85
|
expect(Webpacker.config.compile?).to be true
|
86
86
|
end
|
@@ -190,7 +190,7 @@ describe "Webpacker::Configuration" do
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
-
context "with webpacker config file containing
|
193
|
+
context "with webpacker config file containing manifest_path entry" do
|
194
194
|
config = Webpacker::Configuration.new(
|
195
195
|
root_path: ROOT_PATH,
|
196
196
|
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker_manifest_path.yml", __dir__)),
|
@@ -33,7 +33,7 @@ describe "Generator" do
|
|
33
33
|
describe "shakapacker:install" do
|
34
34
|
context "in a normal Rails project" do
|
35
35
|
before :all do
|
36
|
-
sh_in_dir(SPEC_PATH, "cp -r #{BASE_RAILS_APP_PATH} #{TEMP_RAILS_APP_PATH}")
|
36
|
+
sh_in_dir(SPEC_PATH, "cp -r '#{BASE_RAILS_APP_PATH}' '#{TEMP_RAILS_APP_PATH}'")
|
37
37
|
|
38
38
|
Bundler.with_unbundled_env do
|
39
39
|
sh_in_dir(TEMP_RAILS_APP_PATH, "FORCE=true bundle exec rails shakapacker:install")
|
@@ -65,8 +65,8 @@ describe "Generator" do
|
|
65
65
|
]
|
66
66
|
|
67
67
|
Dir.chdir(path_in_the_app("config/webpack")) do
|
68
|
-
|
69
|
-
expect(
|
68
|
+
existing_files_in_config_webpack_dir = Dir.glob("*")
|
69
|
+
expect(existing_files_in_config_webpack_dir).to eq expected_files
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -94,12 +94,12 @@ describe "Generator" do
|
|
94
94
|
expect(actual_content).to match '<%= javascript_pack_tag "application" %>'
|
95
95
|
end
|
96
96
|
|
97
|
-
it "updates `bin/setup" do
|
97
|
+
it "updates `bin/setup`" do
|
98
98
|
setup_file_content = read(path_in_the_app("bin/setup"))
|
99
99
|
expect(setup_file_content).to match %r(^\s*system!\(['"]bin/yarn['"]\))
|
100
100
|
end
|
101
101
|
|
102
|
-
it "adds relevant shakapacker version in package.json depending on gem version
|
102
|
+
it "adds relevant shakapacker version in package.json depending on gem version" do
|
103
103
|
npm_version = Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(Shakapacker::VERSION)
|
104
104
|
|
105
105
|
actual_content = read(path_in_the_app("package.json"))
|
@@ -26,7 +26,7 @@ describe "Shakapacker::Compiler" do
|
|
26
26
|
allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy)
|
27
27
|
|
28
28
|
status = OpenStruct.new(success?: true)
|
29
|
-
allow(Open3).to receive(:capture3).and_return([:
|
29
|
+
allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status])
|
30
30
|
|
31
31
|
expect(Shakapacker.compiler.compile).to be true
|
32
32
|
expect(mocked_strategy).to have_received(:after_compile_hook)
|
@@ -40,7 +40,7 @@ describe "Shakapacker::Compiler" do
|
|
40
40
|
allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy)
|
41
41
|
|
42
42
|
status = OpenStruct.new(success?: false)
|
43
|
-
allow(Open3).to receive(:capture3).and_return([:
|
43
|
+
allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status])
|
44
44
|
|
45
45
|
expect(Shakapacker.compiler.compile).to be false
|
46
46
|
expect(mocked_strategy).to have_received(:after_compile_hook)
|
@@ -56,7 +56,7 @@ describe "Shakapacker::Configuration" do
|
|
56
56
|
expect(config.cache_manifest?).to be true
|
57
57
|
end
|
58
58
|
|
59
|
-
it "returns false in
|
59
|
+
it "returns false in development environment" do
|
60
60
|
with_rails_env("development") do
|
61
61
|
expect(Shakapacker.config.cache_manifest?).to be false
|
62
62
|
end
|
@@ -74,13 +74,13 @@ describe "Shakapacker::Configuration" do
|
|
74
74
|
expect(config.compile?).to be false
|
75
75
|
end
|
76
76
|
|
77
|
-
it "returns true in
|
77
|
+
it "returns true in development environment" do
|
78
78
|
with_rails_env("development") do
|
79
79
|
expect(Shakapacker.config.compile?).to be true
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
it "returns true in test
|
83
|
+
it "returns true in test environment" do
|
84
84
|
with_rails_env("test") do
|
85
85
|
expect(Shakapacker.config.compile?).to be true
|
86
86
|
end
|
@@ -189,7 +189,7 @@ describe "Shakapacker::Configuration" do
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
-
context "with shakapacker config file containing
|
192
|
+
context "with shakapacker config file containing manifest_path entry" do
|
193
193
|
config = Shakapacker::Configuration.new(
|
194
194
|
root_path: ROOT_PATH,
|
195
195
|
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_manifest_path.yml", __dir__)),
|
@@ -44,7 +44,7 @@ describe "RakeTasks" do
|
|
44
44
|
Dir.chdir(TEST_APP_PATH)
|
45
45
|
end
|
46
46
|
|
47
|
-
context "with existing `./bin/
|
47
|
+
context "with existing `./bin/shakapacker` and `./bin/shakapacker-dev-server`" do
|
48
48
|
it "passes" do
|
49
49
|
expect { system("bundle exec rake shakapacker:check_binstubs") }.to output("").to_stdout_from_any_process
|
50
50
|
end
|
@@ -451,19 +451,19 @@ describe "VersionChecker::NodePackageVersion" do
|
|
451
451
|
context "from exact semantic version" do
|
452
452
|
let(:node_package_version_from_semver_exact) { node_package_version(fixture_version: "semver_exact") }
|
453
453
|
|
454
|
-
it "#raw
|
454
|
+
it "#raw returns version" do
|
455
455
|
expect(node_package_version_from_semver_exact.raw).to eq "6.0.0"
|
456
456
|
end
|
457
457
|
|
458
|
-
it "#major_minor_patch
|
458
|
+
it "#major_minor_patch returns version array" do
|
459
459
|
expect(node_package_version_from_semver_exact.major_minor_patch).to eq ["6", "0", "0"]
|
460
460
|
end
|
461
461
|
|
462
|
-
it "#skip_processing?
|
462
|
+
it "#skip_processing? returns false" do
|
463
463
|
expect(node_package_version_from_semver_exact.skip_processing?).to be false
|
464
464
|
end
|
465
465
|
|
466
|
-
it "#semver_wildcard?
|
466
|
+
it "#semver_wildcard? returns false" do
|
467
467
|
expect(node_package_version_from_semver_exact.semver_wildcard?).to be false
|
468
468
|
end
|
469
469
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shakapacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-08-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -251,6 +251,7 @@ files:
|
|
251
251
|
- package/environments/production.js
|
252
252
|
- package/environments/test.js
|
253
253
|
- package/esbuild/index.js
|
254
|
+
- package/index.d.ts
|
254
255
|
- package/index.js
|
255
256
|
- package/rules/__tests__/__utils__/webpack.js
|
256
257
|
- package/rules/__tests__/babel.js
|
@@ -528,7 +529,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
528
529
|
licenses:
|
529
530
|
- MIT
|
530
531
|
metadata:
|
531
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.0.
|
532
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.0.3
|
532
533
|
post_install_message:
|
533
534
|
rdoc_options: []
|
534
535
|
require_paths:
|