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

Missing modules inside the bundle #1182

Closed
DarkHarlock opened this issue May 14, 2020 · 5 comments · Fixed by #1183
Closed

Missing modules inside the bundle #1182

DarkHarlock opened this issue May 14, 2020 · 5 comments · Fixed by #1183

Comments

@DarkHarlock
Copy link
Contributor

DarkHarlock commented May 14, 2020

I'm submitting a bug report

  • Library Version:
    1.3.1

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Node Version:
    10.13.0

  • NPM Version:
    6.4.1

  • Language:
    TypeScript

  • bundler:
    RequireJS

Current behavior:
If none of the globbing in the source section of bundles intercept some transpiled files, those files are not bundled and no warning/error is reported. This cause runtime errors for the missing modules.

For example changing the default aurelia.json created by the cli with this:

      {
        "name": "app-bundle.js",
        "source": {
          "include": [
            "**/*.{js, css,html}"
          ],
          "exclude": [
            "**/environment.js"
          ]
        }
      },

causes:

image

and no mention about that is reported.

  • What is the expected behavior?
    What is needed is that those files are not captured in the build.bundle() function, so something like this can be written in the transpile pipeline:
  return gulp.src(project.transpiler.dtsSource)
    .pipe(gulp.src(project.transpiler.source, {
      sourcemaps: true,
      since: gulp.lastRun(buildTypeScript)
    }))
    .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
    .pipe(typescriptCompiler())
    .pipe(build.bundle())
    .pipe(reportNotBundledFilesOrDoCustomCopy()); // added step

At this time all files are captured and so there are no possibilities to intercept them.

Checking at the source code the root cause seems to be located mainly in the capture(file) function (at /lib/build/index.js) that always returns undefined (also if the bundler does not subsume it) not allowing more .pipe() steps after it.

  • What is the motivation / use case for changing the behavior?
    Allowing not bundled files to be streamed to other steps (the default template could report them as an error / warning), some manual / custom management can be implemented: suppress, warning, copy the file, or whatelse you need.
    A simple case of customization could be to not bundle the environment.js (or other configuration related files, but can by anything), copy it in the destination folder as a default, and if needed change it during the CI/CD process.
@3cp
Copy link
Member

3cp commented May 14, 2020

Related to #1160

I will probably get the warning in, if @michaelwjackson is busy on other things.

@3cp
Copy link
Member

3cp commented May 14, 2020

I will see if I can let the last bundle file to implicitly bundle everything (what left from other bundles).

@DarkHarlock
Copy link
Contributor Author

DarkHarlock commented May 14, 2020

I prefer the approach of report a warning and allow the developer to manage/solve it.
Implicit not configurable behaviors creates restrictions that not allow integrations.

In my case now, I found this trying to split the bundles just because I want to replace some modules content during the CI/CD process.

If this is solved in the way I suggested I can simplify my build and deploy process, and I think that for any other developer fix it in the aurelia.json is fine.

@3cp
Copy link
Member

3cp commented May 14, 2020

The current fix in #1160 is going to print a warning but not terminate the task.
For your case, I guess what you need is a failure? Not just a console warning.

@DarkHarlock
Copy link
Contributor Author

Yes a warning could be ok.
What I suggest, but I was aware of this kind of problem only for transpile, is to allow the developers to manage it changing a pipe step after the bundle. Here you can log it by default, but also manage with a custom copy implementation.

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 a pull request may close this issue.

2 participants