question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bundle with non relative path

See original GitHub issue

I’m submitting a bug report

  • Library Version: aurelia-cli 0.24

Please tell us about your environment:

  • Operating System: Windows 10

  • Node Version: 5.11.0

  • NPM Version: 3.10.8

  • Browser: all

  • Language: TypeScript 2.1

Current behavior: See this stack overflow question.

When using non-relative path imports, the bundling fails. For instance, if I import a class like this:

import { DialogBox } from '../../resources/elements/dialog-box';

the bundling works whereas if I import it like this: import { DialogBox } from 'resources/elements/dialog-box';

the bundling fails. This happens during the bundling phase of aurelia-cli’s build (with au run --watch) so it means that the typescript compilation worked correctly. VSCode doesn’t complain about either relative or absolute path either… The error I get that interrupts the build:

{ uid: 11, name: 'writeBundles', branch: false, error: { [Error: ENOENT: no such file or directory, open 'C:\Users\GMA\Doc errno: -4058, code: 'ENOENT', syscall: 'open', path: 'C:\\Users\\GMA\\Documents\\Sources\\ProtoSAMWeb\\FluBAO\\D duration: [ 0, 8865477 ], ...

Expected/desired behavior: I’d like the bundling not to fail when using ‘root-relative’ imports.

  • What is the motivation / use case for changing the behavior? Having to use relative path everywhere makes the imports much less clear and harder to maintain for our developers.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
sbolelcommented, Feb 24, 2017

The above two commits fixes the relative paths issue, but show types errors:

custom_typings/aurelia-protractor.d.ts(8,41): error TS2694: Namespace 'protractor' has no exported member 'Protractor'.
[01:58:23] gulp-notify: [Error running Gulp] Error: custom_typings/aurelia-protractor.d.ts(8,41): error TS2694: Namespace 'protractor' has no exported member 'Protractor'.
custom_typings/aurelia-protractor.d.ts(9,56): error TS2694: Namespace 'protractor' has no exported member 'Protractor'.
[01:58:23] gulp-notify: [Error running Gulp] Error: custom_typings/aurelia-protractor.d.ts(9,56): error TS2694: Namespace 'protractor' has no exported member 'Protractor'.
custom_typings/aurelia-protractor.d.ts(14,36): error TS2503: Cannot find namespace 'webdriver'.
[01:58:23] gulp-notify: [Error running Gulp] Error: custom_typings/aurelia-protractor.d.ts(14,36): error TS2503: Cannot find namespace 'webdriver'.
[01:58:23] TypeScript: 3 semantic errors
[01:58:23] TypeScript: emit succeeded (with errors)

Will get back to that shortly.

Full Bash session testing a build with a newly generated app in this Gist.

1reaction
sbolelcommented, Feb 23, 2017

I didn’t read your question well, did I? haha 😅 How about updating these packages:

npm i -D gulp-typescript@^3.1.5 typings@^2.1.0 aurelia-tools@^1.0.0

I noticed my ts files weren’t making it into my bundle as well even though I did not see any errors. Updating these packages seems to have fixed it.

Before:

$ au build
Starting 'readProjectConfiguration'...
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processCSS'...
Starting 'configureEnvironment'...
Finished 'processCSS'
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildTypeScript'...
Finished 'buildTypeScript'
Starting 'writeBundles'...
Tracing app...          # where is main, lib, etc?
Tracing aurelia-binding...
Tracing aurelia-bootstrapper...
Tracing aurelia-dependency-injection...
Tracing aurelia-event-aggregator...
Tracing aurelia-framework...
Tracing aurelia-history...
Tracing aurelia-history-browser...
Tracing aurelia-loader-default...
Tracing aurelia-logging-console...
Tracing aurelia-route-recognizer...
Tracing aurelia-router...
Tracing aurelia-templating-binding...
Tracing text...
Tracing aurelia-templating-resources...
Tracing aurelia-templating-router...
Tracing aurelia-testing...
Writing app-bundle.js...
Writing vendor-bundle.js...
Finished 'writeBundles'

After:

$ au build
Starting 'readProjectConfiguration'...
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processCSS'...
Starting 'configureEnvironment'...
Finished 'processCSS'
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildTypeScript'...
gulp-typescript: ts(tsProject) has been deprecated - use .pipe(tsProject(reporter)) instead
  As of gulp-typescript 3.0, .pipe(ts(tsProject)) should be written as .pipe(tsProject()).
  More information: http://dev.ivogabe.com/gulp-typescript-3/
Finished 'buildTypeScript'
Starting 'writeBundles'...
Tracing app...          # NEW!
Tracing environment...  # NEW!
Tracing main...         # NEW!
Tracing app...
Tracing aurelia-binding...
Tracing aurelia-bootstrapper...
Tracing aurelia-dependency-injection...
Tracing aurelia-event-aggregator...
Tracing aurelia-framework...
Tracing aurelia-history...
Tracing aurelia-history-browser...
Tracing aurelia-loader-default...
Tracing aurelia-logging-console...
Tracing aurelia-pal-browser...
Tracing aurelia-route-recognizer...
Tracing aurelia-router...
Tracing aurelia-templating-binding...
Tracing text...
Tracing aurelia-templating-resources...
Tracing aurelia-templating-router...
Tracing aurelia-testing...
Writing app-bundle.js...
Writing vendor-bundle.js...
Finished 'writeBundles'
Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack cannot resolve non relative path generated by tsc
The problem occurs when I am compiling a different package ( packageB ) using webpack that consumes packageA. I have main in packageA...
Read more >
Documentation - Module Resolution - TypeScript
Use non-relative paths when importing any of your external dependencies. ... In our example, if Node.js found the file /root/src/moduleB/package.json ...
Read more >
How to resolve a relative path inside a bundle - Juju
Relative paths are resolved relative to the path of the entity that describes them. That is, relative to the overlay bundle file itself....
Read more >
Module Resolution - webpack
In this case, the directory of the source file where the import or require occurs is taken to be the context directory. The...
Read more >
Say bye to relative paths in TypeScript | by Vincent Schoener
If you go for it, you will have to duplicate all the path in the tsconfig.json file to package.json and it's not convenient...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found