Skip to content
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

Move modifyAssetLocation from build options to the config (for when path option is used) #346

Conversation

robinborst95
Copy link
Contributor

@robinborst95 robinborst95 commented Dec 1, 2021

This PR adds a failing test to confirm #344. This test does basically the same as #345 (I copied the snapshot as that should be the exact same), but this test uses the --path option and therefore fails.

@robinborst95 robinborst95 force-pushed the feature/modify-asset-location-path-option branch from 8e4eccd to 3a69bd3 Compare December 3, 2021 09:36
@robinborst95 robinborst95 changed the title Add failing test for modifyAssetLocation when path option is used Add failing test for modifyAssetLocation when path option is used (+ attempt to fix it) Dec 3, 2021
@robinborst95
Copy link
Contributor Author

robinborst95 commented Dec 3, 2021

@thoov @rwjblue , I did an attempt to fix the issue by also looking up modifyAssetLocation in the config. It does fix my added test, but I can imagine you prefer a more generic solution, like always having to define this in the config for example. An even better solution would be having access to the build options from the this.project or this.parent, but I didn't know if and how that is possible. Could any of you shed some light on this?

Edit: I have tested this fix with our codebase and it does indeed work.

Copy link
Collaborator

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

Hmm. This seems important to do, thank you @robinborst95!

It seems not great that you might have to duplicate, or even that you have to decide that you want to use the config file vs ember-cli-build.js 🤔

@rwjblue
Copy link
Collaborator

rwjblue commented Dec 7, 2021

An even better solution would be having access to the build options from the this.project or this.parent, but I didn't know if and how that is possible. Could any of you shed some light on this?

You could (in your config) instantiate the Project (via require('ember-cli/models/project').closestSync, or we could pass it in as an argument when invoking the config function 🤔

@robinborst95
Copy link
Contributor Author

It seems not great that you might have to duplicate, or even that you have to decide that you want to use the config file vs ember-cli-build.js

@rwjblue I agree, I think it should work that either the config file or the ember-cli-build file defines the function then. I could find how to get the latter working though. I tried looking into the source code how the build works, and if I understand correctly, the modifyAssetLocation function would be in the lib/broccoli/ember-app's options (so, app.options['ember-cli-code-coverage'].modifyAssetLocation). However, this app is never returned (it's returned as app.toTree()), so I don't see how this can be accessed other than during the build process itself (which, again, happens separately when using the path option, so that's not an option).

The other option of having it in the config file makes a lot more sense to me at all actually, as the modifyAssetLocation function has not so much to do with the build of the files, but instead it has more to do with how/where those files should be reported. Fixing this would be easy, as I have it working already, it just requires some simplification and a modification in the readme.

You could (in your config) instantiate the Project

I don't see how this would help this addon detect the modifyAssetLocation actually, could you elaborate (if still relevant after my explanation of the options above)?

@robinborst95
Copy link
Contributor Author

@rwjblue @thoov any thoughts on my previous comment?

@rmachielse
Copy link
Contributor

@rwjblue @thoov any chance this could get some attention soon? We are desperate to use the 2.0 beta as it reduces our build time by minutes, but this issue is keeping us from using it.

@rwjblue
Copy link
Collaborator

rwjblue commented Jan 18, 2022

The other option of having it in the config file makes a lot more sense to me at all actually, as the modifyAssetLocation function has not so much to do with the build of the files, but instead it has more to do with how/where those files should be reported. Fixing this would be easy, as I have it working already, it just requires some simplification and a modification in the readme.

@robinborst95 - Let's do it! 😸

@robinborst95 robinborst95 force-pushed the feature/modify-asset-location-path-option branch 2 times, most recently from 47c8271 to f053ec0 Compare January 19, 2022 10:31
@robinborst95 robinborst95 force-pushed the feature/modify-asset-location-path-option branch from f053ec0 to 83f57d8 Compare January 19, 2022 10:33
@robinborst95 robinborst95 changed the title Add failing test for modifyAssetLocation when path option is used (+ attempt to fix it) Move modifyAssetLocation from build options to the config (for when path option is used) Jan 19, 2022
Copy link
Contributor Author

@robinborst95 robinborst95 left a comment

Choose a reason for hiding this comment

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

@rwjblue thanks for your response! I've gone ahead and moved modifyAssetLocation from the build options to the config, and also updated the Readme accordingly. I've tested this in our own app as well and I can confirm it works.

The `forceModulesToBeLoaded` can potientally cause unindented side effects when executed. You can pass custom filter fuctions that allow
### `forceModulesToBeLoaded`

The `forceModulesToBeLoaded` function can potentially cause unintended side effects when executed. You can pass custom filter fuctions that allow
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found some typos here while I was at it

@@ -124,19 +118,15 @@ module.exports = {
attachMiddleware.serverMiddleware(startOptions.app, {
configPath: this.project.configPath(),
root: this.project.root,
fileLookup: this.fileLookup,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this as well, as this is a leftover from the 1.0 version

@robinborst95 robinborst95 requested a review from rwjblue January 19, 2022 10:55
@robinborst95
Copy link
Contributor Author

@rwjblue @kategengler any chance this PR can be reviewed soon 🙏 ?

@joostverdoorn
Copy link

We would love to start using it, thanks @robinborst95 for working on this. @rwjblue @kategengler any chance we can get this merged?

@rmachielse
Copy link
Contributor

@rwjblue @kategengler can you please consider merging this? This has been open for almost a year.

@kategengler
Copy link
Collaborator

Unfortunately with the rewrite by @thoov and @rwjblue (which I am grateful for -- it means the package works on modern Ember!), I am not familiar enough with the code to review. Maybe one of them can take a look?

@rwjblue rwjblue merged commit 53fa201 into ember-cli-code-coverage:master Jan 10, 2023
@robinborst95 robinborst95 deleted the feature/modify-asset-location-path-option branch April 20, 2023 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants