Skip to content

How to handle CommonJS modules, e.g. import foo = require('foo'); ? #46

@fuhrmanator

Description

@fuhrmanator

See #35 (CommonJS lazy-loading case)

import foo = require('foo'); results in an identifier foo: any. How should we represent this in Famix? A NamedEntity doesn't have a type. A Module is not quite the same as a CommonJS module (which is like a black box to some degree).

A solution could be to create CommonJSModule someplace (under StructuralEntity or under NamedEntity?) which allows for a Type definition, and when the parser encounters import x = require('blah') we just make an instance of this CommonJSModule with a type any.

CommonJSModule would not have a lot of info in Famix, but perhaps we can see the dependencies through ImportClauses.

I am thinking with AMD modules we could also do a similar thing. However, AMD doesn't always use import syntax, so I'm not sure it's easy to support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions