-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow using nested entries #121
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c83240a
Allow using nested entries
justin808 d738383
fix tests
justin808 06b6848
Update docs
justin808 74bba02
Update tests
justin808 9b4447b
tests
justin808 0e5c5f3
add missing file
justin808 1b0c521
Update changelog.md
justin808 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ _Please add entries here for your pull requests that are not yet released._ | |
|
||
- Removed the `yarn:install` Rake task, and no longer enhance `assets:precompile` with said task. These tasks were used to ensure required NPM packages were installed before asset precompilation. Going forward you will need to ensure these packages are already installed yourself. Should you wish to restore this behaviour you'll need to [reimplement the task](https://github.com/shakacode/shakapacker/blob/bee661422f2c902aa8ac9cf8fa1f7ccb8142c914/lib/tasks/yarn.rake) in your own application. | ||
|
||
## Added | ||
- Configuration boolean option `nested_entries` to use nested entries. This was the default prior to v6.0. Because entries maybe generated, it's useful to allow a `generated` subdirectory. | ||
|
||
## [v6.3.0] - May 19, 2022 | ||
|
||
### Improved | ||
|
@@ -41,7 +44,7 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions | |
### Improved | ||
- Use last modified timestamps rather than file digest to determine compiler freshness. [PR 97](https://github.com/shakacode/shakapacker/pull/97) by [tomdracz](https://github.com/tomdracz). | ||
|
||
Rather than calculating SHA digest of all the files in the paths watched by the compiler, we are now comparing the modified time of the `manifest.json` file versues the latest modified timestamp of files and directories in watched paths. Unlike calculating digest, which only looked at the files, the new calculation also considers directory timestamps, including the parent ones (i.e. `config.source_path` folder timestamp will be checked together will timestamps of all files and directories inside of it). | ||
Rather than calculating SHA digest of all the files in the paths watched by the compiler, we are now comparing the modified time of the `manifest.json` file versus the latest modified timestamp of files and directories in watched paths. Unlike calculating digest, which only looked at the files, the new calculation also considers directory timestamps, including the parent ones (i.e. `config.source_path` folder timestamp will be checked together will timestamps of all files and directories inside of it). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
|
||
This change should result in improved compiler checks performance but might be breaking for certain setups and edge cases. If you encounter any issues, please report them at https://github.com/shakacode/shakapacker/issues. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,16 @@ | |
// environment.js expects to find config/webpacker.yml and resolved modules from | ||
// the root of a Rails project | ||
|
||
const { chdirTestApp, chdirCwd } = require('../../utils/helpers') | ||
const { chdirTestApp, chdirCwd, resetEnv } = require('../../utils/helpers') | ||
|
||
chdirTestApp() | ||
|
||
const { resolve } = require('path') | ||
const rules = require('../../rules') | ||
const baseConfig = require('../base') | ||
|
||
describe('Base config', () => { | ||
beforeEach(() => jest.resetModules() && resetEnv()) | ||
|
||
afterAll(chdirCwd) | ||
|
||
describe('config', () => { | ||
|
@@ -21,11 +22,26 @@ describe('Base config', () => { | |
) | ||
}) | ||
|
||
test('should return multi file entry points', () => { | ||
test('should return only 2 entry points with config.nested_entries == false', () => { | ||
expect(baseConfig.entry.multi_entry.sort()).toEqual([ | ||
resolve('app', 'packs', 'entrypoints', 'multi_entry.css'), | ||
resolve('app', 'packs', 'entrypoints', 'multi_entry.js') | ||
]) | ||
expect(baseConfig.entry['generated/something']).toEqual(undefined) | ||
}) | ||
|
||
test('should return only 3 entry points with config.nested_entries == true', () => { | ||
process.env.WEBPACKER_CONFIG = 'config/webpacker_nested_entries.yml' | ||
require('../../config.js') | ||
const baseConfig = require('../base') | ||
|
||
expect(baseConfig.entry.multi_entry.sort()).toEqual([ | ||
resolve('app', 'packs', 'entrypoints', 'multi_entry.css'), | ||
resolve('app', 'packs', 'entrypoints', 'multi_entry.js') | ||
]) | ||
expect(baseConfig.entry['generated/something']).toEqual( | ||
resolve('app', 'packs', 'entrypoints', 'generated', 'something.js') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is failing ATM |
||
) | ||
}) | ||
|
||
test('should return output', () => { | ||
|
@@ -36,6 +52,8 @@ describe('Base config', () => { | |
}) | ||
|
||
test('should return default loader rules for each file in config/loaders', () => { | ||
const rules = require('../../rules') | ||
|
||
const defaultRules = Object.keys(rules) | ||
const configRules = baseConfig.module.rules | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Note: You must restart bin/webpacker-dev-server for changes to take effect | ||
|
||
default: &default | ||
source_path: app/packs | ||
source_entry_path: entrypoints | ||
nested_entries: true | ||
public_root_path: public | ||
public_output_path: packs | ||
cache_path: tmp/webpacker | ||
webpack_compile_output: false | ||
webpack_loader: babel | ||
|
||
# Location for manifest.json, defaults to {public_output_path}/manifest.json if unset | ||
# manifest_path: public/packs/manifest.json | ||
|
||
# Additional paths webpack should look up modules | ||
# ['app/assets', 'engine/foo/app/assets'] | ||
additional_paths: | ||
- app/assets | ||
- /etc/yarn | ||
- some.config.js | ||
- app/elm | ||
|
||
# Reload manifest.json on all requests so we reload latest compiled packs | ||
cache_manifest: false | ||
|
||
static_assets_extensions: | ||
- .jpg | ||
- .jpeg | ||
- .png | ||
- .gif | ||
- .tiff | ||
- .ico | ||
- .svg | ||
|
||
extensions: | ||
- .mjs | ||
- .js | ||
|
||
development: | ||
<<: *default | ||
compile: true | ||
ensure_consistent_versioning: true | ||
|
||
# Reference: https://webpack.js.org/configuration/dev-server/ | ||
dev_server: | ||
https: false | ||
host: localhost | ||
port: 3035 | ||
public: localhost:3035 | ||
hmr: false | ||
overlay: true | ||
disable_host_check: true | ||
use_local_ip: false | ||
pretty: false | ||
|
||
test: | ||
<<: *default | ||
compile: true | ||
|
||
# Compile test packs to a separate directory | ||
public_output_path: packs-test | ||
|
||
production: | ||
<<: *default | ||
|
||
# Production depends on precompilation of packs prior to booting for performance. | ||
compile: false | ||
|
||
# Cache manifest.json for performance | ||
cache_manifest: true | ||
|
||
staging: | ||
<<: *default | ||
|
||
# Production depends on precompilation of packs prior to booting for performance. | ||
compile: false | ||
|
||
# Cache manifest.json for performance | ||
cache_manifest: true | ||
|
||
# Compile staging packs to a separate directory | ||
public_output_path: packs-staging |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justin808 can we add something in the readme suggesting when you would want to use that and examples?