Skip to content

Commit d0b76e2

Browse files
authored
fix: Enable es-modules by default. (#889)
A previous fix for #796 added an es-modules option and set it false by default. This default was a change of behavior in NYC as previously all sources were parsed as ES modules by the instrumenter. I believe the old behavior is the correct default because it allows NYC to work with modern code. Code which uses certain features which violate strict mode will have to disable es-modules. This will not effect ES5 which follows the rules of 'use strict'.
1 parent 6b6cd5e commit d0b76e2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/config-util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Config.buildYargs = function (cwd) {
116116
global: false
117117
})
118118
.option('es-modules', {
119-
default: false,
119+
default: true,
120120
type: 'boolean',
121121
describe: 'tell the instrumenter to treat files as ES Modules',
122122
global: false

test/nyc-bin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ describe('the nyc cli', function () {
10351035
const args = [
10361036
bin,
10371037
'--cache', 'false',
1038+
'--es-modules', 'false',
10381039
process.execPath, './not-strict.js'
10391040
]
10401041

@@ -1065,7 +1066,6 @@ describe('the nyc cli', function () {
10651066
const args = [
10661067
bin,
10671068
'--cache', 'false',
1068-
'--es-modules', 'true',
10691069
'--exit-on-error', 'true',
10701070
process.execPath, './not-strict.js'
10711071
]

0 commit comments

Comments
 (0)