From 0da58e1d1d103a2a27ad865882086112649a4011 Mon Sep 17 00:00:00 2001
From: Thomas Fritsch <tf@kumquats.fr>
Date: Fri, 7 Feb 2020 16:55:07 +0100
Subject: [PATCH] B.2. Compiler avec Babel

---
 .babelrc          |  3 ++-
 js/main.js        | 13 ++++++++++++-
 package-lock.json | 24 ++++++++++++++++++++++++
 package.json      |  7 ++++---
 4 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/.babelrc b/.babelrc
index dfb789c..0af6804 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,3 +1,4 @@
 {
-	"presets": ["@babel/env"]
+	"presets": ["@babel/env"],
+	"plugins": ["@babel/plugin-proposal-class-properties"]
 }
\ No newline at end of file
diff --git a/js/main.js b/js/main.js
index 807180b..daca832 100644
--- a/js/main.js
+++ b/js/main.js
@@ -20,4 +20,15 @@ const data = [
 		prix_grande: 8,
 		image: 'https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300'
 	}
-];
\ No newline at end of file
+];
+
+class Animal {
+	constructor( name ){
+		this.name = name;
+	}
+	fly() { // déclaration de méthode
+		console.log(`${this.name} is flying !`);
+	}
+}
+const threeEyedRaven = new Animal( 'Bran' );
+threeEyedRaven.fly();
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 1b1cf6e..a9499ca 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -136,6 +136,20 @@
         "semver": "^5.5.0"
       }
     },
+    "@babel/helper-create-class-features-plugin": {
+      "version": "7.8.3",
+      "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.8.3.tgz",
+      "integrity": "sha512-qmp4pD7zeTxsv0JNecSBsEmG1ei2MqwJq4YQcK3ZWm/0t07QstWfvuV/vm3Qt5xNMFETn2SZqpMx2MQzbtq+KA==",
+      "dev": true,
+      "requires": {
+        "@babel/helper-function-name": "^7.8.3",
+        "@babel/helper-member-expression-to-functions": "^7.8.3",
+        "@babel/helper-optimise-call-expression": "^7.8.3",
+        "@babel/helper-plugin-utils": "^7.8.3",
+        "@babel/helper-replace-supers": "^7.8.3",
+        "@babel/helper-split-export-declaration": "^7.8.3"
+      }
+    },
     "@babel/helper-create-regexp-features-plugin": {
       "version": "7.8.3",
       "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.8.3.tgz",
@@ -347,6 +361,16 @@
         "@babel/plugin-syntax-async-generators": "^7.8.0"
       }
     },
+    "@babel/plugin-proposal-class-properties": {
+      "version": "7.8.3",
+      "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.8.3.tgz",
+      "integrity": "sha512-EqFhbo7IosdgPgZggHaNObkmO1kNUe3slaKu54d5OWvy+p9QIKOzK1GAEpAIsZtWVtPXUHSMcT4smvDrCfY4AA==",
+      "dev": true,
+      "requires": {
+        "@babel/helper-create-class-features-plugin": "^7.8.3",
+        "@babel/helper-plugin-utils": "^7.8.3"
+      }
+    },
     "@babel/plugin-proposal-dynamic-import": {
       "version": "7.8.3",
       "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.8.3.tgz",
diff --git a/package.json b/package.json
index e229001..334a953 100644
--- a/package.json
+++ b/package.json
@@ -4,15 +4,16 @@
   "description": "",
   "main": "index.js",
   "scripts": {
-	"test": "echo \"Error: no test specified\" && exit 1",
-	"build": "babel js -d build",
-	"watch": "babel js -d build --verbose --watch --source-maps"
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "build": "babel js -d build",
+    "watch": "babel js -d build --verbose --watch --source-maps"
   },
   "author": "thomas.fritsch@univ-lille.fr",
   "license": "ISC",
   "devDependencies": {
     "@babel/cli": "^7.8.4",
     "@babel/core": "^7.8.4",
+    "@babel/plugin-proposal-class-properties": "^7.8.3",
     "@babel/preset-env": "^7.8.4"
   }
 }
-- 
GitLab