Open CanKattwinkel opened 6 years ago
It's great to see my rx-queue
has been used in your Angular project!
This issue was caused by we try to get the npm version from the package.json, but we have only used it in the node.js environment before, and in the Angular bundle environment, there's no package.json at all, because the code was bundled.
I had just added a commit to fix this, please try the latest version v 0.4.28, and let me know if this issue was fixed.
Thanks for reporting this, have a good day!
It still happens in 0.4.28.
How did this happen?
We had already catch all exceptions:
https://github.com/zixia/rx-queue/blob/8179faa5443c57b331f72e4a04a6fc5af6524cc3/src/config.ts#L1-L11
I'm having the same problem with Angular 6 as well.
As far as I can tell, the VERSION (and corresponding version() function) aren't actually used for anything. Once I removed the VERSION grabbing stuff locally the package still worked without issue.
Will try this module: https://github.com/rollup/rollup-plugin-json
@zixia
Why does the version needs to be part of the bundle? If anyone is interested in the version he/she would require the package.json file from the node_modules folder.
@CanKattwinkel The version needs to be part of the bundle because I want to get the version from the instance.
This issue should have been fixed from rx-queue@0.6
or above, please feel free to let me know if there still have any problems.
@zixia I agree with @CanKattwinkel - there's no actual need for returning the actual version number from the package. This is the first and only package I've ever come across that does it, and it's the only one that has this particular problem - so the two are definitely related.
What does it do? It returns the version of the package
Why? Because we want to run it in smoke tests to check the package has loaded correctly.
What problem is it causing? In Angular 6+ (which quite a lot of people will be using this with) it errors that the package.json cannot be found, leading to runtime errors (not compile time).
How can this be fixed? The easiest way to fix this is to return a static value from the existing function as not to break backwards compatibility.
This was the thinking behind the pull request that's now been closed (because you've done all the work yourself anyway, rendering it moot) - and I believe your approach to this problem is incorrect.
@footballencarta thank you for your pull request and sharing your thinking behind the PR.
As I said in reply to your PR, we need to keep it working by fix the problem under angular 6 instead of hard coded the version number inside the source code.
From rx-queue@0.6, the rollup will get the version number from the package.json to the bundle automatically, just like what your PR does.
Hello,
I tried to use your lib in an Angular project. Sadly it doesn't work due to some build error.
Steps to reproduce:
ng new queue-error
cd queue-error
yarn add rx-queue
@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'queue-error';
ngOnInit() { const queue = new RxQueue() queue.next(1) queue.next(2) queue.next(3)
}
}