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

failure upon require('./file.js') or require('module/') #579

Closed
gravsten opened this issue Apr 2, 2017 · 7 comments · Fixed by #862
Closed

failure upon require('./file.js') or require('module/') #579

gravsten opened this issue Apr 2, 2017 · 7 comments · Fixed by #862

Comments

@gravsten
Copy link

gravsten commented Apr 2, 2017

I'm submitting a bug report

  • Library Version:
    0.27.0

Please tell us about your environment:

  • Operating System:
    Windows 8.1

  • Node Version:
    6.10.0

  • NPM Version:
    3.10.10

Current behavior:
Tracing fails to find appropriate file when using require('./file.js') or require('module/')

Expected/desired behavior:
aurelia-cli should add '.js' only when omitted in the library code, and remove any trailing '/'.

  • What is the motivation / use case for changing the behavior?
    The purpose of using node/npm is to reuse and automatically update libraries in one's project.
    With the aforementioned bug, one needs to edit all offending libraries for 'au run' to work flawlessly (while other bundlers show no such problem).
@JeroenVinke
Copy link
Collaborator

Hi, can you provide the error messages for both statements? Thanks

@JeroenVinke JeroenVinke added the bug label Apr 2, 2017
@gravsten
Copy link
Author

gravsten commented Apr 2, 2017

The error message is the regular "File not found" error.

@JeroenVinke
Copy link
Collaborator

The first issue, where the CLI does not handle imports with the .js extension correctly, looks to be the same as #533.

About the second issue, require('module/') throwing an error, isn't this a user error? Just checked, and SystemJS has the same behavior.

@gravsten
Copy link
Author

gravsten commented Apr 7, 2017

About the second issue, some dependencies PouchDB exihibit such quirks.
I have built my Aurelia app successfully with SystemJS 0.16.52, but now that I am porting to Aurelia-CLI 0.27.0 this has become a problem.
Anyway, I believe the comparison with SystemJS is irrelevant because require('module/') is unambiguous and thus should be handled gracefully without raising an error (even through some optional switch in Aurelia-CLI, e.g. '--fuzz').
The only other option is for all Aurelia devs to start hunt and manually correct those quirks until the dependencies' authors get around the issue. Not my preferred choice.

@JeroenVinke
Copy link
Collaborator

JeroenVinke commented Apr 7, 2017

About the second issue, some dependencies PouchDB exihibit such quirks.

That changes things. What exact package did you have issues with? I'd like to do my testing on that. Is it pouchdb or a subdependency?

@gravsten
Copy link
Author

gravsten commented Apr 7, 2017

You will get many errors if you try to add the following PouchDB libraries:

pouchdb-adapter-idb@6.1.2
pouchdb-adapter-localstorage@6.1.2
pouchdb-adapter-memory@6.1.2
pouchdb-adapter-websql@6.1.2
pouchdb-core@6.1.2
pouchdb-promise@6.1.2

To start with, some libs (e.g. levelup, readable-stream) fail to declare all their dependencies according to the Aurelia-CLI tracer (e.g. util). So you have to manually update their package.json (and aurelia.json) with the missing dependencies.

And among those libs, readable-stream is by far the worst offender and the reason I had to give up (for now) trying to include levelup in my package.

One of the problems with readable-stream, and probably the easiest to resolve, is the call to
StringDecoder = require('string_decoder/').StringDecoder;
in readable-stream\lib_stream_readable.js

@JeroenVinke
Copy link
Collaborator

@gravsten Thanks for the instructions. The pouchdb thing, having to declare that many package dependencies, is not good, at all. I'm going to use pouchdb as the test case for #530.

One of the problems with readable-stream, and probably the easiest to resolve, is the call to
StringDecoder = require('string_decoder/').StringDecoder;
in readable-stream\lib_stream_readable.js

I will look into this, and also #581

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

Successfully merging a pull request may close this issue.

2 participants