Skip to content

Commit

Permalink
Remove experimentalModules option
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 10, 2021
1 parent 4119923 commit 8eb81bb
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 36 deletions.
1 change: 0 additions & 1 deletion lib/generate/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function config(ctx) {
main = resolveFrom(mainRoot, mainId)
} catch {}

ctx.experimentalModules = options.experimentalModules || false
ctx.cwd = cwd
ctx.main = main
ctx.name = options.name || pkg.name || null
Expand Down
2 changes: 0 additions & 2 deletions lib/generate/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export async function instrument(ctx) {

return {
visitor: {
// Not tested on dubnium. Remove when tests are Node 12+
/* c8 ignore next 3 */
ImportDeclaration(path) {
instrumentMainReference(path.node.source)
},
Expand Down
13 changes: 3 additions & 10 deletions lib/generate/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ const exec = promisify(cp.exec)

export async function run(ctx) {
const logs = ctx.logs
const cmd = [process.execPath]

// Not tested on dubnium. Remove when tests are Node 12+
/* c8 ignore next 3 */
if (ctx.experimentalModules) {
cmd.push('--experimental-modules')
}

cmd.push(ctx.exampleInstrumentedPath)

let result

try {
result = await exec(cmd.join(' '))
result = await exec(
[process.execPath, ctx.exampleInstrumentedPath].join(' ')
)
} catch (error) {
throw new Error('Could not run example: ' + error)
}
Expand Down
9 changes: 0 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ If given, resolved from [`file.cwd`][file-cwd].
If inferred from `package.json`, resolved relating to that package root.
Used to rewrite `require('.')` to `require('name')`.

###### `options.experimentalModules`

Pass [`--experimental-modules`][experimental-modules] when running the example
in Node.
This lets you use ECMAScript Modules if the current version of Node does support
this flag, but *does not* support ES modules natively.

## Security

Use of `remark-usage` is unsafe because `main` and `example` are executed.
Expand Down Expand Up @@ -230,8 +223,6 @@ abide by its terms.

[file-cwd]: https://github.com/vfile/vfile#vfilecwd

[experimental-modules]: https://nodejs.org/api/esm.html

[usage]: #use

[example-js]: example.js
Expand Down
3 changes: 0 additions & 3 deletions test/fixtures/es-module-type-module/config.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 1 addition & 11 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {isHidden} from 'is-hidden'
import remarkUsage from '../index.js'

const root = path.join('test', 'fixtures')
let fixtures = fs.readdirSync(root)
const fixtures = fs.readdirSync(root)

fs.writeFileSync(
path.join(root, 'fail-could-not-parse-example', 'example.js'),
Expand All @@ -33,16 +33,6 @@ test('remarkUsage', (t) => {
t.end()
})

// Ignore es modules below Node 12.
const version = Number.parseInt(process.version.slice(1), 10)

if (version < 12) {
fixtures = fixtures.filter((f) => {
const prefix = 'es-module'
return f.slice(0, prefix.length) !== prefix
})
}

test('Fixtures', async (t) => {
let index = -1

Expand Down

0 comments on commit 8eb81bb

Please sign in to comment.