Glamorous Toolkit is now beta. Read more.

Analyzing JavaScript, JSX/React systems

JavaScript is supported through several internal JavaScript importers and parsers.

Importing plain JavaScript

Glamorous Toolkit ships with a built in parser and abstract syntax tree implementation for JavaScript.

model := (GtJSImporter new 
  parserClass: JSParser; 
  importDirectory: baseDir) model

Importing JSX/React

Importing React works in the same way, only with a more enhanced parser to handle JSX and a specialized importer for React components.

model := (GtReactImporter new 
  parserClass: JSXParser; 
  importDirectory: baseDir) model

Parsing JavaScript

jsFile := 'PATH/TO/FILE.js' asFileReference.
JSParser parse: jsFile contents

Parsing JSX

jsFile := 'PATH/TO/FILE.js' asFileReference.
JSXParser parse: jsFile contents