dependents / node-ast-module-types Goto Github PK
View Code? Open in Web Editor NEWAST helpers for recognizing CommonJS, AMD, and ES6 module types
License: MIT License
AST helpers for recognizing CommonJS, AMD, and ES6 module types
License: MIT License
Add the following test in test/tests.js
. Run npm test
and notice that fails:
assert.ok(check("define(['jquery'] , ($) => { class A {} return A;});", types.isDefineAMD));
Checkout version 2.7.0, which has commit hash of f5c2a2c
. Execute the same test and notice that now it passes. This might be a regression of #18, although I'm not sure about it.
I think this issue belongs here, but might belong in module-definition
.
I found a false positive with ansi-colors, which has a top-level define
, but it (ahem) defines define
itself. module-definition
thinks this is an AMD module.
I'm not sure how this should be addressed. Should module-definition
only consider a module to be AMD if define
is used as a global? Or if define
has a certain specific signature? Unsure if the change should live in module-definition
or here or both.
If you can point me in the right direction, I may be able to send a PR to address it.
thanks!
Currently doesn't handle:
exports = function() {
}
The AST for that uses an AssignmentExpression
:
{
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "Identifier",
"name": "exports"
},
"right": {
"type": "FunctionExpression",
"id": null,
"params": [],
"defaults": [],
"body": {
"type": "BlockStatement",
"body": []
},
"rest": null,
"generator": false,
"expression": false
}
}
}
]
}
A non-module JS file that has a define()
signature nested somewhere that matches one of the requirejs define
forms.
https://github.com/amdjs/amdjs-api/blob/master/AMD.md#using-require-and-exports
define(function (require, exports, module) {
var a = require('a'),
b = require('b');
exports.action = function () {};
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.