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

Identifier 'Ajv' has already been declared while migrating to Angular6 #281

Open
vatsalpande opened this issue May 14, 2018 · 15 comments
Open

Comments

@vatsalpande
Copy link

Issue type

I'm submitting a (check one):
[x] Bug report
[ ] Feature request
[ ] Regression (something that used to work, but stopped working in a newer version)
[ ] Support request
[ ] Documentation issue or request

Prerequisites

Before posting, make sure you do the following (check all):
[x] Confirm you are using the latest versions of all necessary packages (or if not, explain why not)
[x] Search GitHub for a similar issue or PR

Current behavior

While running ng serve below error is being thrown

ERROR in ./node_modules/angular2-json-schema-form/angular2-json-schema-form.es5.js
Module parse failed: Identifier 'Ajv' has already been declared (7:12)
You may need an appropriate loader to handle this file type.

On checking angular2-json-schema-form.es5.js - there are two entries for
import * as Ajv from 'ajv';

If one of the entry is removed manually, this error goes away

Expected behavior

No error should be thrown while building the project

IMPORTANT: How can we reproduce your problem?

Just include angular2-json-schema-form in a newly configured angular cli project and run ng serve

Environment

OS name & version: macOS Sierra
Browser name & version:
Angular version: 6
Angular JSON Schema Form version(s): ^0.7.0-alpha.1

@lucasgranberg
Copy link

I have the same problem. The import seems to stem from https://github.com/dschnelldavis/angular2-json-schema-form/blob/master/build.js#L129. I am not familiar with the build process but I removed it in my fork and it seems to build fine.

@neil-coutinho
Copy link

Any way I can update this w/o modifying the code in my node_modules folder?

@3c
Copy link

3c commented May 29, 2018

I have the same problem . because exports error component in xx.module.ts

@NgModule({
  exports: [
    CheckBoxComponent   // this is error line
    CheckboxListComponent
  ]
})

I write a component named 'CheckboxListComponent' , but spell wrong word in exports . 'CheckBoxComponent' belongs to Material

After delete the wrong line code ,it's fine

@Mathijs003
Copy link

@neil-coutinho any progress on this error?

@neil-coutinho
Copy link

@Mathijs003 No I simply commented out the duplicate import * as Ajv from 'ajv' statement as mentioned above

@hamzahamidi
Copy link

I made a PR to solve this issue. I hope it will get merged soon #295

hamzahamidi added a commit to hamzahamidi/angular2-json-schema-form that referenced this issue Jun 29, 2018
Signed-off-by: Hamza Hamidi <hamidihamzacg@gmail.com>
@hamzahamidi
Copy link

hamzahamidi commented Jun 29, 2018

For people who can't wait for this update to get merged here's a quick fix:

$ npm install git+https://github.com/hamzahamidi/angular2-json-schema-form.git#build-angular-6 --save

You may need to install @angular/flex manually: $ npm i @angular/flex-layout
Once this branch get merged, I'll delete the branch so it will not work anymore, in respect to the repo's owner

@trsh
Copy link

trsh commented Jul 12, 2018

With this version Im getting other problems:

core.js:1870 ERROR RangeError: Maximum call stack size exceeded at isNumber (angular2-json-schema-form.es5.js:213) at isEqual (angular2-json-schema-form.es5.js:6708) at isEqual (angular2-json-schema-form.es5.js:6712) at isEqual (angular2-json-schema-form.es5.js:6712) at isEqual (angular2-json-schema-form.es5.js:6712) at isEqual (angular2-json-schema-form.es5.js:6712) at isEqual (angular2-json-schema-form.es5.js:6712) at isEqual (angular2-json-schema-form.es5.js:6712) at isEqual (angular2-json-schema-form.es5.js:6712) at isEqual (angular2-json-schema-form.es5.js:6712)

when dealing with enums

@trsh
Copy link

trsh commented Jul 12, 2018

It's whenever I select non-first option for enum in dropdown :/

@hamzahamidi
Copy link

hamzahamidi commented Jul 12, 2018

@trsh I fixed that error in the last commit. I think I didn't update the bundles. I'll do it asap

@trsh
Copy link

trsh commented Jul 12, 2018

From bedugger

var isEqual = function (enumValue, inputValue) {
                return enumValue === inputValue ||
                    (isNumber(enumValue) && +inputValue === +enumValue) ||
                    (isBoolean(enumValue, 'strict') &&
                        toJavaScriptType(inputValue, 'boolean') === enumValue) ||
                    (enumValue === null && !hasValue(inputValue)) ||
                    isEqual(enumValue, inputValue);
            };

The last line creates an inf recursion :(

I dont understand. It's supposed to be a lodash fn, but it's compiled like local

@trsh
Copy link

trsh commented Jul 12, 2018

@hamzahamidi

another issue is #300, but I can't tell if its your version or old issue, because I can't install not-your-version :D

@hamzahamidi
Copy link

@trsh I can't seem to reproduce your issue did you try delete your package-lock.json & run:

 npm install git+https://github.com/hamzahamidi/angular2-json-schema-form.git#build-angular-6 --save

@trsh
Copy link

trsh commented Jul 12, 2018

The first issue is fixed. Duno exactly how. I did a lot of things :). But now that isEqual appears as it should be, with WB wrapper.
The second is more an angular thing.

Tnx for your time.

@EricsG95
Copy link

Thank you for the PR @trsh! Hopefully it gets merged soon or the issues be rectified.

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

No branches or pull requests

8 participants