Skip to content

Commit b284a6c

Browse files
committed
Upgrade Babel 7
1 parent 5b40407 commit b284a6c

11 files changed

+1868
-1723
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"presets": [
33
[
4-
"env",
4+
"@babel/preset-env",
55
{
66
"targets": {
77
"browsers": ["last 2 versions"]

ng-annotate-main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const assert = require("assert");
88
const ngInject = require("./nginject");
99
const scopeTools = require("./scopetools");
1010
// const optionalAngularDashboardFramework = require("./optionals/angular-dashboard-framework");
11-
const t = require('babel-types');
11+
const t = require('@babel/types');
1212

1313

1414
const chainedRouteProvider = 1;

nginject.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"use strict";
66

77
const is = require("simple-is");
8-
const t = require('babel-types');
9-
const codeFrame = require("babel-code-frame");
8+
const t = require('@babel/types');
9+
const codeFrame = require("@babel/code-frame");
1010

1111
module.exports = {
1212
inspectComment: inspectComment,

package-lock.json

+1,835-1,690
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
"url": "https://github.com/schmod/babel-plugin-angularjs-annotate"
99
},
1010
"dependencies": {
11-
"babel-code-frame": "^6.26.0",
12-
"babel-types": "^6.26.0",
11+
"@babel/code-frame": "7.0.0-beta.44",
12+
"@babel/types": "7.0.0-beta.44",
1313
"simple-is": "~0.2.0"
1414
},
1515
"devDependencies": {
16-
"babel-core": "^6.26.0",
17-
"babel-preset-env": "^1.6.0",
16+
"@babel/core": "7.0.0-beta.44",
17+
"@babel/preset-env": "7.0.0-beta.44",
1818
"babelify": "^7.3.0",
1919
"browserify": "^13.1.0",
2020
"chalk": "^1.1.1",

scopetools.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"use strict";
66

77
const is = require("simple-is");
8-
const t = require("babel-types");
8+
const t = require("@babel/types");
99

1010
module.exports = {
1111
isReference: isReference

tests/es6.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
this.dep1 = dep1;
2020
}
2121
}
22-
svc.$inject = ['dep1'];
22+
svc.$inject = ["dep1"];
2323
angular.module('MyMod').service('MySvc', svc);
2424
}
2525
},
@@ -42,7 +42,7 @@ module.exports = {
4242
this.dep1 = dep1;
4343
}
4444
}
45-
svc.$inject = ['dep1'];
45+
svc.$inject = ["dep1"];
4646
angular.module('MyMod').service('MySvc', svc);
4747
`
4848
},
@@ -69,7 +69,7 @@ module.exports = {
6969
}
7070
`,
7171
expected: `
72-
_ngInjectExport.$inject = ['$timeout'];
72+
_ngInjectExport.$inject = ["$timeout"];
7373
export default function _ngInjectExport($timeout) {
7474
'ngInject';
7575
return 'foo';
@@ -95,7 +95,7 @@ module.exports = {
9595
this.dep1 = dep1;
9696
}
9797
}
98-
svc.$inject = ['dep1'];
98+
svc.$inject = ["dep1"];
9999
svc.foo = 'bar';
100100
}
101101
},
@@ -119,7 +119,7 @@ module.exports = {
119119
this.dep1 = dep1;
120120
}
121121
}
122-
svc.$inject = ['dep1'];
122+
svc.$inject = ["dep1"];
123123
svc.foo = 'bar';
124124
`
125125
},
@@ -143,7 +143,7 @@ module.exports = {
143143
return 'foo';
144144
}
145145
}
146-
_ngInjectAnonymousClass.$inject = ['$timeout'];
146+
_ngInjectAnonymousClass.$inject = ["$timeout"];
147147
`
148148
},
149149
{
@@ -165,7 +165,7 @@ module.exports = {
165165
this.dep1 = dep1;
166166
}
167167
}
168-
svc.$inject = ['dep1'];
168+
svc.$inject = ["dep1"];
169169
svc.foo = 'bar';
170170
}
171171
},
@@ -188,7 +188,7 @@ module.exports = {
188188
this.dep1 = dep1;
189189
}
190190
}
191-
svc.$inject = ['dep1'];
191+
svc.$inject = ["dep1"];
192192
svc.foo = 'bar';
193193
}
194194
}, {
@@ -203,7 +203,7 @@ module.exports = {
203203
},
204204
expected: function() {
205205
var foo = {
206-
bar: ['baz', function(baz) {
206+
bar: ["baz", function(baz) {
207207
'ngInject';
208208
}]
209209
}
@@ -218,7 +218,7 @@ module.exports = {
218218
},
219219
expected: function() {
220220
angular.component('myComponent', {
221-
controller: ['a', function(a){}]
221+
controller: ["a", function(a){}]
222222
});
223223
}
224224
}

tests/issues.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ module.exports = {
214214
var inside = function ($q) {
215215
'ngInject';
216216
};
217-
inside.$inject = ['$q'];
217+
inside.$inject = ["$q"];
218218
return inside;
219219
};
220220
},
@@ -231,9 +231,9 @@ module.exports = {
231231
};
232232
},
233233
expected: function(){
234-
module.exports = ['$filterProvider', function($filterProvider) {
234+
module.exports = ["$filterProvider", function($filterProvider) {
235235
'ngInject';
236-
ordinalSuffixFilter.$inject = ['ordinalSuffix'];
236+
ordinalSuffixFilter.$inject = ["ordinalSuffix"];
237237
function ordinalSuffixFilter(ordinalSuffix) {
238238
'ngInject';
239239
}

tests/ngInject-arrow.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ module.exports = {
270270
$stateProvider.state('astate', {
271271
resolve: {
272272
/* @ngInject */
273-
yoyo: ['ma', (ma) => {
273+
yoyo: ["ma", (ma) => {
274274
}],
275275
}
276276
});
277277
};
278-
MyDirective2.$inject = ['$stateProvider'];
278+
MyDirective2.$inject = ["$stateProvider"];
279279
}
280280
}
281281
].map(t => { t.explicit=true; return t; })

tests/ngInject.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,14 @@ module.exports = {
374374
}
375375
},
376376
expected: function(){
377-
MyDirective2.$inject = ['$stateProvider'];
377+
MyDirective2.$inject = ["$stateProvider"];
378378

379379
/* @ngInject */
380380
function MyDirective2($stateProvider) {
381381
$stateProvider.state('astate', {
382382
resolve: {
383383
/* @ngInject */
384-
yoyo: ['ma', function(ma) {
384+
yoyo: ["ma", function(ma) {
385385
}],
386386
}
387387
});

tests/tests.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const babel = require('babel-core');
3+
const babel = require('@babel/core');
44
const diff = require('diff');
55
const chalk = require('chalk');
66
const indent = require('indent-string');
@@ -10,7 +10,7 @@ const path = require('path');
1010
const resolve = (file) => path.resolve(__dirname, file);
1111

1212
const ES6presets = [
13-
[ "env", { exclude: ['transform-es2015-function-name'] } ]
13+
[ "@babel/preset-env", { exclude: ['transform-function-name'] } ]
1414
];
1515

1616
const plugin = resolve("../babel-ng-annotate.js");
@@ -81,22 +81,22 @@ function runTest(test) {
8181

8282
function doTransform(t, test, presets, logPrefix){
8383

84-
let out = babel.transform(fnBody(test.input), { plugins: [plugin], presets: presets });
85-
let expected = babel.transform(fnBody(test.expected), { plugins: [], presets: presets });
84+
let out = babel.transform(fnBody(test.input), { plugins: [plugin], presets: presets, compact: true });
85+
let expected = babel.transform(fnBody(test.expected), { plugins: [], presets: presets, compact: true });
8686

8787
t.equals(out.code.trim().replace(/\n/g,''), expected.code.trim().replace(/\n/g,''), logPrefix + ': ' + test.name);
8888

8989
// If test is marked as explicit, it should still work when explicitOnly is on
9090
if(test.explicit){
91-
out = babel.transform(fnBody(test.input), { plugins: [[plugin, {explicitOnly: true}]], presets:presets });
91+
out = babel.transform(fnBody(test.input), { plugins: [[plugin, {explicitOnly: true}]], presets:presets, compact: true });
9292

9393
t.equals(out.code.trim().replace(/\n/g,''), expected.code.trim().replace(/\n/g,''), logPrefix + ' explicitOnly: ' + test.name);
9494
}
9595

9696
// If test is marked as implicit, no transformation should occur when explicitOnly is on
9797
if(test.implicit){
98-
out = babel.transform(fnBody(test.input), { plugins: [[plugin, {explicitOnly: true}]], presets: presets });
99-
expected = babel.transform(fnBody(test.input), { plugins: [], presets: presets });
98+
out = babel.transform(fnBody(test.input), { plugins: [[plugin, {explicitOnly: true}]], presets: presets, compact: true });
99+
expected = babel.transform(fnBody(test.input), { plugins: [], presets: presets, compact: true });
100100

101101
t.equals(out.code.trim().replace(/\n/g,''), expected.code.trim().replace(/\n/g,''), logPrefix + 'explicitOnly: ' + test.name);
102102
}

0 commit comments

Comments
 (0)