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

Comments

Projects
None yet
2 participants
@gravsten

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

This comment has been minimized.

Show comment
Hide comment
@JeroenVinke

JeroenVinke Apr 2, 2017

Member

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

Member

JeroenVinke commented Apr 2, 2017

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

@JeroenVinke JeroenVinke added the bug label Apr 2, 2017

@gravsten

This comment has been minimized.

Show comment
Hide comment
@gravsten

gravsten Apr 2, 2017

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

gravsten commented Apr 2, 2017

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

@JeroenVinke

This comment has been minimized.

Show comment
Hide comment
@JeroenVinke

JeroenVinke Apr 7, 2017

Member

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.

Member

JeroenVinke commented Apr 7, 2017

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

This comment has been minimized.

Show comment
Hide comment
@gravsten

gravsten 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.

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

This comment has been minimized.

Show comment
Hide comment
@JeroenVinke

JeroenVinke Apr 7, 2017

Member

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?

Member

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

This comment has been minimized.

Show comment
Hide comment
@gravsten

gravsten 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

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

This comment has been minimized.

Show comment
Hide comment
@JeroenVinke

JeroenVinke Apr 8, 2017

Member

@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

Member

JeroenVinke commented Apr 8, 2017

@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

JeroenVinke added a commit to JeroenVinke/cli that referenced this issue Apr 8, 2017

@JeroenVinke JeroenVinke added the bundler label May 25, 2017

huochunpeng added a commit to huochunpeng/cli that referenced this issue Sep 6, 2018

feat: fully support package.json browser field
Support (1) alternative main, (2) replace specific files, (3) ignore a module.
Cleanup dependency string ending in '/' or '.js'.

closes aurelia#579, aurelia#581

huochunpeng added a commit to huochunpeng/cli that referenced this issue Sep 6, 2018

feat: fully support package.json browser field
Support (1) alternative main, (2) replace specific files, (3) ignore a module.
Cleanup dependency string ending in '/' or '.js'.

closes aurelia#579, aurelia#581

huochunpeng added a commit to huochunpeng/cli that referenced this issue Sep 13, 2018

feat: fully support package.json browser field
Support (1) alternative main, (2) replace specific files, (3) ignore a module.
Cleanup dependency string ending in '/' or '.js'.

closes aurelia#579, aurelia#581

huochunpeng added a commit to huochunpeng/cli that referenced this issue Sep 14, 2018

feat(bundler): fully support package.json browser field
Support (1) alternative main, (2) replace specific files, (3) ignore a module.
Cleanup dependency string ending in '/' or '.js'.

closes aurelia#579, aurelia#581

huochunpeng added a commit to huochunpeng/cli that referenced this issue Sep 14, 2018

feat(bundler): fully support package.json browser field
Support (1) alternative main, (2) replace specific files, (3) ignore a module.
Cleanup dependency string ending in '/' or '.js'.

closes aurelia#579, aurelia#581

huochunpeng added a commit to huochunpeng/cli that referenced this issue Sep 25, 2018

feat(bundler): fully support package.json browser field
Support (1) alternative main, (2) replace specific files, (3) ignore a module.
Cleanup dependency string ending in '/' or '.js'.

closes aurelia#579, aurelia#581

huochunpeng added a commit to huochunpeng/cli that referenced this issue Sep 27, 2018

feat(bundler): fully support package.json browser field
Support (1) alternative main, (2) replace specific files, (3) ignore a module.
Cleanup dependency string ending in '/' or '.js'.

closes aurelia#579, aurelia#581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment