angular2-json-schema-form icon indicating copy to clipboard operation
angular2-json-schema-form copied to clipboard

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

Open vatsalpande opened this issue 6 years ago • 15 comments

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

vatsalpande avatar May 14 '18 00:05 vatsalpande

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.

lucasgranberg avatar May 16 '18 10:05 lucasgranberg

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

neil-coutinho avatar May 18 '18 04:05 neil-coutinho

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

3c avatar May 29 '18 08:05 3c

@neil-coutinho any progress on this error?

Mathijs003 avatar Jun 14 '18 13:06 Mathijs003

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

neil-coutinho avatar Jun 15 '18 04:06 neil-coutinho

I made a PR to solve this issue. I hope it will get merged soon https://github.com/dschnelldavis/angular2-json-schema-form/pull/295

hamzahamidi avatar Jun 28 '18 14:06 hamzahamidi

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

hamzahamidi avatar Jun 29 '18 14:06 hamzahamidi

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 avatar Jul 12 '18 11:07 trsh

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

trsh avatar Jul 12 '18 11:07 trsh

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

hamzahamidi avatar Jul 12 '18 11:07 hamzahamidi

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 avatar Jul 12 '18 11:07 trsh

@hamzahamidi

another issue is https://github.com/dschnelldavis/angular2-json-schema-form/issues/300, but I can't tell if its your version or old issue, because I can't install not-your-version :D

trsh avatar Jul 12 '18 12:07 trsh

@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

hamzahamidi avatar Jul 12 '18 12:07 hamzahamidi

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.

trsh avatar Jul 12 '18 12:07 trsh

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

EricsG95 avatar Jul 23 '18 10:07 EricsG95