SlideShare a Scribd company logo
Меняем JavaScript
с помощью JavaScript
Павел Волокитин
const React = require('react');
import React from 'react';
const React = require('react');
import React from 'react';
/const (w+) = require('([^']+'));/
→ import $1 from '$2';
forEach(arr, function(item) {
console.log(item);
});
for (const item of arr) {
console.log(item);
}
define(['react'], function(React) {
return {...};
});
const React = require('react');
module.exports = {...};
AMD
CommonJS
Abstract Syntax Tree
1 + 2 + 3
Abstract Syntax Tree
1 + 2 + 3
BinaryExpr +
BinaryExpr +
1 2
3
Abstract Syntax Tree
1 + 2 + 3
BinaryExpr +
BinaryExpr +
1 2
3
console.log(123)
Abstract Syntax Tree
1 + 2 + 3
BinaryExpr +
BinaryExpr +
1 2
3
console.log(123)
CallExpr
MemberExpr
Identifier
"console"
Identifier
"log"
123
Abstract Syntax Tree
jscodeshift
astexplorer.net
Demo: astexplorer
–Parse
–Find
–Replace
–Print
react-codemod
const Comp = React.createClass({
getDefaultProps() {
return {size: 10};
},
getInitialState() {
return {focused: false};
},
render() {...},
});
class Comp extends React.Component {
static defaultProps = {size: 10};
state = {focused: false};
render() {...}
}
Demo: React class
–Parse
–Find
–Replace
–Print
Demo: nuclide outline
Demo: react-docgen
Demo: modules
Трудности
–Parse
–Find
–Replace
–Print
–Parse
–Find
–Replace
–Print
recast
function f(a, b) {
...
}
function fn(
argumentOne,
argumentTwo,
) {
...
}
obj = {
one: 1,
two: 2,
};
obj = {
func() {},
value: null,
};
Меняем javascript с помощью javascript
– recast/lib/printer.js
const React = require('react');
obj = {
one: 1,
two: 2,
};
– recast/lib/printer.js
– Временные ноды
$$newline;
$$newline,
$$newline,
const React = require('react');
obj = {
one: 1,
two: 2,
};
– recast/lib/printer.js
– Временные ноды
Спасибо

More Related Content

PPTX
ES6 in Real Life
PDF
Mozilla とブラウザゲーム
PDF
Ns2: Introduction - Part I
DOCX
C++ file
PDF
Ns2: OTCL - PArt II
PDF
Debugging, a step away from the console
PDF
Think Async: Asynchronous Patterns in NodeJS
PDF
All you need to know about Callbacks, Promises, Generators
ES6 in Real Life
Mozilla とブラウザゲーム
Ns2: Introduction - Part I
C++ file
Ns2: OTCL - PArt II
Debugging, a step away from the console
Think Async: Asynchronous Patterns in NodeJS
All you need to know about Callbacks, Promises, Generators

What's hot (20)

PDF
NS2: AWK and GNUplot - PArt III
PPTX
Correcting Common Async/Await Mistakes in .NET
PPTX
Correcting Common .NET Async/Await Mistakes
PDF
ECMAScript 6
PDF
オープンデータを使ったモバイルアプリ開発(応用編)
PPT
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
PDF
Map kit light
PDF
Multi qubit entanglement
ODP
EcmaScript 6
PDF
Google App Engine Developer - Day3
PPTX
Angular2 rxjs
PDF
Data structure programs in c++
PDF
Explaining ES6: JavaScript History and What is to Come
PDF
Understanding the nodejs event loop
PDF
ES6 - Next Generation Javascript
PPT
NS2: Binding C++ and OTcl variables
PDF
The Ring programming language version 1.5.2 book - Part 74 of 181
PDF
Js interpreter interpreted
PDF
Compose Async with RxJS
PPTX
The redux saga begins
NS2: AWK and GNUplot - PArt III
Correcting Common Async/Await Mistakes in .NET
Correcting Common .NET Async/Await Mistakes
ECMAScript 6
オープンデータを使ったモバイルアプリ開発(応用編)
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Map kit light
Multi qubit entanglement
EcmaScript 6
Google App Engine Developer - Day3
Angular2 rxjs
Data structure programs in c++
Explaining ES6: JavaScript History and What is to Come
Understanding the nodejs event loop
ES6 - Next Generation Javascript
NS2: Binding C++ and OTcl variables
The Ring programming language version 1.5.2 book - Part 74 of 181
Js interpreter interpreted
Compose Async with RxJS
The redux saga begins
Ad

Viewers also liked (13)

PPTX
Atmosfera Matteo Contoli
PPT
Talk for nano Autumn school revised with links to films
PPS
Grupo escolar
PPT
鹿沢レポ 木道のすすめ20110924 柳澤泰男
PPTX
PPTX
Un portal del conocimiento
PPT
to quit or not to quit
PDF
Learning Agreement Final
PDF
O Cenário Social de The Walking Dead: a catarse do grande público com os risc...
PPTX
Mapa conceitual guerra civil espanhola
PPT
CMC Teacher Education SIG Presentation; Masats & Ambròs
PPTX
Energía eólica
Atmosfera Matteo Contoli
Talk for nano Autumn school revised with links to films
Grupo escolar
鹿沢レポ 木道のすすめ20110924 柳澤泰男
Un portal del conocimiento
to quit or not to quit
Learning Agreement Final
O Cenário Social de The Walking Dead: a catarse do grande público com os risc...
Mapa conceitual guerra civil espanhola
CMC Teacher Education SIG Presentation; Masats & Ambròs
Energía eólica
Ad

Similar to Меняем javascript с помощью javascript (20)

PPTX
Academy PRO: ES2015
PDF
Rcpp11 useR2014
PDF
Code examples javascript ebook
PDF
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018
PDF
Javascript
PDF
ClojureScript loves React, DomCode May 26 2015
PPTX
ES6 Overview
PPTX
EcmaScript unchained
PDF
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
PDF
JavaScript 2016 for C# Developers
PPT
Expert JavaScript tricks of the masters
PDF
Refactoring to Macros with Clojure
PDF
Imugi: Compiler made with Python
PDF
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
DOC
code for quiz in my sql
PDF
JJUG CCC 2011 Spring
PPTX
Fact, Fiction, and FP
PPTX
MiamiJS - The Future of JavaScript
PPTX
(Rx).NET' way of async programming (.NET summit 2017 Belarus)
PPS
Ecma script 5
Academy PRO: ES2015
Rcpp11 useR2014
Code examples javascript ebook
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018
Javascript
ClojureScript loves React, DomCode May 26 2015
ES6 Overview
EcmaScript unchained
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
JavaScript 2016 for C# Developers
Expert JavaScript tricks of the masters
Refactoring to Macros with Clojure
Imugi: Compiler made with Python
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
code for quiz in my sql
JJUG CCC 2011 Spring
Fact, Fiction, and FP
MiamiJS - The Future of JavaScript
(Rx).NET' way of async programming (.NET summit 2017 Belarus)
Ecma script 5

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Digital Strategies for Manufacturing Companies
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Transform Your Business with a Software ERP System
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
L1 - Introduction to python Backend.pptx
PDF
Nekopoi APK 2025 free lastest update
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
history of c programming in notes for students .pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administration Chapter 2
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Digital Strategies for Manufacturing Companies
2025 Textile ERP Trends: SAP, Odoo & Oracle
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Transform Your Business with a Software ERP System
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Understanding Forklifts - TECH EHS Solution
Wondershare Filmora 15 Crack With Activation Key [2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How Creative Agencies Leverage Project Management Software.pdf
top salesforce developer skills in 2025.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
L1 - Introduction to python Backend.pptx
Nekopoi APK 2025 free lastest update
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
history of c programming in notes for students .pptx
Operating system designcfffgfgggggggvggggggggg
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administration Chapter 2

Меняем javascript с помощью javascript