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

Remove the File not found or not accessible tracing warning and declare runtime only modules #802

Closed
DarkHarlock opened this issue Jan 14, 2018 · 1 comment

Comments

@DarkHarlock
Copy link
Contributor

I'm submitting a feature request

  • Library Version:
    0.32.0

Please tell us about your environment:

  • Operating System:
    All

  • Node Version:
    7.10.0

  • NPM Version:
    4.2.0

  • Browser:
    all

  • Language:
    all

  • Loader/bundler:
    all

Current behavior:

When a module is only available at deploy/run time the builder reports something like:

Tracing app...
 ------- File not found or not accessible ------
| Location: D:/vscode/cli-test/src/my-awesome-module.js
| Requested by: D:/vscode/cli-test/src/app.js
| Is this a package? Make sure that it is configured in aurelia.json and that it is not a Node.js package
 -----------------------------------------------
  • What is the expected behavior?

This report is very useful to detect missing files or dependencies, but in some cases, for known dependencies, this behavior requires a way to be overridden.

On my side what I need is an entrypoint inside the aurelia.json where I can specify a list of modules to stub with some related dependencies.

It could be something like:

{
  "name": "cli-test",
  "build": {
    "loader": {
      "externalModules": {
        "my-awesome-module": ["infrastructure/service1", "other"]
      }

where my-awesome-module is the missing file reported by the build and infrastructure/service1 and other are some dependencies of the declared module that must exists inside this build.
So, if the previous configuration is applied and the following report is displayed, I can regard it as a build issue.

Tracing app...
 ------- File not found or not accessible ------
| Location: D:/vscode/cli-test/src/other.js
| Requested by: D:/vscode/cli-test/src/app.js
| Is this a package? Make sure that it is configured in aurelia.json and that it is not a Node.js package
 -----------------------------------------------

After some investigation on your code I found that this can be solved intercepting the amodro-trace dependency tracking using the readFile function parameter passed to the trace call. Here you can inject some custom content for my-awesome-module like define(['infrastructure/service1', 'other'], function() {}).

The hook, adapted from the Non-file inputs section of the amodro-trace documentation example, can be something like:

fileRead: function(defaultRead, id, filePath) {
  if (id in loaderOptions.externalModules) {
    let externalContent = makeModuleContent(loaderOptions.externalModules[id]); // return "define(['infrastructure/service1', 'other'], function() {})"
    return externalContent;
  }
  //...

If you are interested on this and the possible solution listed above is acceptable I can provide a PR in the next days.

  • What is the motivation / use case for changing the behavior?

There are mostly 2 use cases that needs this, and are:

  • modules defined at runtime using a call to the define method
  • modules available only at deploy time eg. plugins, for customer customization, bundles from other projects, etc ...
@JeroenVinke
Copy link
Collaborator

Yes!! I am definitely interested, as this could also play a role in adding electron support. Thank you for looking into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants