dschnelldavis / angular2-json-schema-form

Angular 2 JSON Schema Form builder
MIT License
285 stars 177 forks source link

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

Open vatsalpande opened 6 years ago

vatsalpande commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

3c commented 6 years ago

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 commented 6 years ago

@neil-coutinho any progress on this error?

neil-coutinho commented 6 years ago

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

hamzahamidi commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

hamzahamidi commented 6 years ago

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

trsh commented 6 years ago

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 commented 6 years ago

@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

hamzahamidi commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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