Skip to content

Add backward compatibility#252

Merged
justin808 merged 36 commits intoshakapacker-v6.7from
add-backward-compatibility
Mar 17, 2023
Merged

Add backward compatibility#252
justin808 merged 36 commits intoshakapacker-v6.7from
add-backward-compatibility

Conversation

@ahangarha
Copy link
Copy Markdown
Contributor

@ahangarha ahangarha commented Feb 18, 2023

  • Add backward compatibility for
    • Config file (config/shakapacker.yml)
    • shakapacker_precompile entry in the config file
    • Environment Variables
    • --debug-shakapacker option (Without test)
  • Update documentation
  • Add Ruby tests
  • Add JS tests
  • Show deprecation message in
    • Rake tasks
    • Accessing config/webpacker.yml in Ruby
    • Calling ./bin/webapcker
    • Using WEBPACKER_XYZ environment variables
    • Use --debug-webpacker option

Some points:

  • Though I ensure to see a deprecation message in some tests in the output, not all the cases are covered.
  • Some features are not covered by our tests. So they are not covered in these tests (as of the time of writing this description)
  • I have manually tested backward compatibility on react_on_rails_demo_ssr_hmr project.

@ahangarha ahangarha changed the title WIP - add backward compatibility WIP - Add backward compatibility Feb 18, 2023
@ahangarha ahangarha force-pushed the add-backward-compatibility branch from 241c00f to df64a02 Compare February 20, 2023 16:04
Comment thread lib/shakapacker/configuration.rb Outdated
@vaukalak
Copy link
Copy Markdown
Contributor

Otherwise LGTM

@ahangarha ahangarha force-pushed the add-backward-compatibility branch 2 times, most recently from b34a1f6 to 22a9a63 Compare February 24, 2023 18:03
strategy:
matrix:
os: [ubuntu-latest]
ruby: ['2.6', '2.7', '3.0']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.1?

Copy link
Copy Markdown
Contributor Author

@ahangarha ahangarha Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are okay with updating our test environment in this PR, I can do it. But also we can do it in a separate PR.

My proposal:
Ruby:

- ruby: ['2.6', '2.7', '3.0']
+ ruby: ['2.7', '3.0', '3.2']

Node:

- node: [12.x, 14.x, 16.x]
+ node: [14.x, 16.x, 18.x]

Copy link
Copy Markdown
Contributor Author

@ahangarha ahangarha Mar 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justin808
What about this?

Maybe better to discuss this for v7.

Comment thread lib/shakapacker/configuration.rb
Comment thread lib/shakapacker/configuration.rb Outdated
Comment thread lib/shakapacker/configuration.rb Outdated
Comment thread lib/shakapacker/deprecation_helper.rb Outdated
Comment thread package/utils/helpers.js Outdated
Comment thread package/utils/helpers.js Outdated
Comment thread package/utils/helpers.js Outdated
Comment thread spec/backward_compatibility_specs/webpacker_test_app/.gitignore Outdated
@@ -0,0 +1,24 @@
require_relative "test_app/config/environment"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name needs to be more descriptive, maybe with some comments at the beginning of this file

why is this code separate from spec_helper.rb?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we run this code with a before_each? this file got required in many different files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid we can do this unless we want to initialize a new Rails.application for each single test case, which is expensive.

This would be a temporary implementation till Version 7. From version 7 and dropping backward compatibility, we go back to what we used to be.

I agree about the filename. The file initializes a Rails application and sets Shakapacker or Webpacker configuration. Maybe app_initializer would be a better name. I am afraid if I give it such a name and leave the file in the same directory as other spec files, we cannot recognize it easily. Maybe put it in a helper directory? Not sure of the best approach.

@ahangarha ahangarha force-pushed the add-backward-compatibility branch 2 times, most recently from 4dde39b to 255c291 Compare February 28, 2023 10:39
@ahangarha ahangarha marked this pull request as ready for review February 28, 2023 15:46
@ahangarha ahangarha changed the title WIP - Add backward compatibility Add backward compatibility Feb 28, 2023
@ahangarha ahangarha force-pushed the webpacker-to-shakapacker branch from 2776578 to 60ccf1c Compare March 7, 2023 09:56
@ahangarha ahangarha force-pushed the add-backward-compatibility branch 2 times, most recently from a197740 to 2b9440e Compare March 7, 2023 11:42
@justin808
Copy link
Copy Markdown
Member

Ready?

Comment thread docs/v7_upgrade.md Outdated
Comment thread docs/v7_upgrade.md Outdated
Comment thread docs/v7_upgrade.md Outdated
Comment thread docs/v7_upgrade.md Outdated
Comment thread docs/v7_upgrade.md Outdated
Comment thread docs/v7_upgrade.md Outdated
Comment thread lib/shakapacker/configuration.rb Outdated
Comment thread lib/shakapacker/deprecation_helper.rb

def get_config_file_path_with_backward_compatibility(config_path)
if config_path.to_s.end_with?("shakapacker.yml") && !File.exist?(config_path)
webpacker_config_path = if config_path.class == Pathname
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not formatted correctly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubocop forces me to use such indentation. We have this rule:

Use 2 (not 26) spaces for indentation.
(convention:Layout/IndentationWidth)

Comment thread package/rules/__tests__/__utils__/webpack.js
@ahangarha ahangarha force-pushed the add-backward-compatibility branch from 09d3ee7 to 80636f6 Compare March 12, 2023 14:00
Base automatically changed from webpacker-to-shakapacker to shakapacker-v6.7 March 13, 2023 09:00
@ahangarha ahangarha force-pushed the add-backward-compatibility branch from 8a3a0b6 to fca217a Compare March 13, 2023 19:40
Comment thread CHANGELOG.md Outdated

# For backward compatibility
Shakapacker.set_shakapacker_env_variables_for_backward_compatibility
@config_path = Pathname.new(ENV["SHAKAPACKER_CONFIG"] || config_path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this done somewhere else in a prior PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which line?

If 17, no.

For line no.18, I found it challenging to set config path from env when we do it in Instance class. This way, I let the configuration class make the final decision about the config path.

Perhaps it was better to do it in the renaming PR. Yet, this is just internal change.

Comment thread lib/shakapacker/configuration.rb Outdated
Comment thread lib/shakapacker/configuration.rb Outdated
@justin808 justin808 merged commit a4a15f3 into shakapacker-v6.7 Mar 17, 2023
@justin808 justin808 deleted the add-backward-compatibility branch March 17, 2023 07:09
ahangarha added a commit that referenced this pull request Apr 19, 2023
* Use Shakapacker module, config filesm, and env variables
* Rename rake files to shakapacker
* Update JS code and tests
* Fix conflict
* Update Readme and contribution guide for shakapacker
* Remove debug lines
* Fix linter issue
* Use Shakapacker module, config filesm, and env variables
* Add support for old configfile
* Add rake tasks
* Add files to support requiring Webpacker module
* Add backward compatibility test
* Add rake task for backward compatibility test
* Add CI for backward compatibility specs
* Add backward compatibility to JS package
* Add backward compatibility for --debug-shakapacker option
* Fix chdir in afterAll hook in js tests
* Fix js tests for compiling files in source_path
* Use symlink address for config file
* Use fs.existsSync to check if file exist
* Remove a redundant assignment
* Improve deprecation messages
* Improve gitignore in test apps
* Improve deprecation message for env variables
* Update documentation
* Show deprecation message for old binstubs
* Update changelog
* Add and improve test for custom config path in env variable
* Improve robustness in config.fetch method
* Update docs
* Update deprecation message
* Simplify config.fetch method
* Remove lines releated to git conflict
* Improve the order of code
* Add v7 upgrade guide link to changelog
ahangarha added a commit that referenced this pull request Apr 27, 2023
* Rename Webpacker instances to shakapacker (#245)
* Add backward compatibility (#252)
* Update docs for spelling change (#263)
* Fix backward compatibility for setting WEBPACKER_CONFIG in webpack.config.js (#266)
* Remove redundant code for enhancing precompile task (#270)
* Update webpack dev server configuration (#276)
* Stop stripping top level dirs (#283)
* Improve source_entry_path robustness (#284)

---------

Co-authored-by: Tom Dracz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants