sylvainpolletvillard / ObjectModel

Strong Dynamically Typed Object Modeling for JavaScript
http://objectmodel.js.org
MIT License
467 stars 30 forks source link

depcheck reports ObjectModel as missing and objectmodel as unused #81

Closed gotjoshua closed 6 years ago

gotjoshua commented 6 years ago

Here is (some of) the output of depcheck:

Unused dependencies
* objectmodel
Unused devDependencies
* babel-plugin-import
Missing dependencies
* ObjectModel

I guess this has to do with import methods:

I am using this style (in several files): var ObjectModel = require('ObjectModel').ObjectModel; When I replace one of those require statements with: import { ObjectModel } from 'objectmodel'; then the unused dependency goes away.

Is this "normal" ?

sylvainpolletvillard commented 6 years ago

the package name is lowercase. Try var ObjectModel = require('objectmodel').ObjectModel;

gotjoshua commented 6 years ago

Interesting situation: I am using meteor, and I think the issue had something to do with mixed styles of import and require...

when i use this:

import { ObjectModel, SetModel } from 'objectmodel';
var BasicModel = require('ObjectModel').BasicModel;

i get this error (on the require line):

Uncaught Error: Cannot find module 'ObjectModel'
   in modules-runtime.js?hash=7f4df5777c8321c08a58834753e5d5a010366eda:218 
gotjoshua commented 6 years ago

ok, getting more weird:

when i use this (in the same file as above):

var ObjectModel = require('ObjectModel').ObjectModel;
var SetModel = require('ObjectModel').SetModel;
var BasicModel = require('ObjectModel').BasicModel;

then it throws an error in a different file that is using the recommended syntax:

import { ObjectModel } from 'objectmodel';
...
Uncaught Error: Cannot find module 'objectmodel'

but if i convert all uses of ObjectModel to the CamelCase require, then there are no errors.

Perhaps it has something to do with babel / meteor's legacy conversion stuff.

Anyyyywayyyy - i will convert to the import syntax from now on.

sylvainpolletvillard commented 6 years ago

The package name is supposed to be lowercase. I highly suggest you to use lowercase everywhere, no matter if you are using CommonJS or ES Modules.

gotjoshua commented 6 years ago

Yeah, I get that now... just don't understand why it would only work (or work at all for that matter) with CamelCase with require at one point... but i'll let it pass as a quirk and follow your suggestion. Thanks.