Node: esm: Make `import.meta.resolve(…)` take an options argument

Created on 19 Feb 2020  ·  1Comment  ·  Source: nodejs/node

require.resolve(…) takes a second optional options argument, instead of a second optional parent string argument.

This differs from what's been implemented in https://github.com/nodejs/node/pull/31032.

import.meta.resolve(…) and require.resolve(…) should both take a string and an options object, instead of one taking two strings and the other taking a string and an options object.


/cc @guybedford

Most helpful comment

@ExE-Boss the intent of the api is to make something that could also be implemented / standardized for browser use cases... so it is not using require.resolve as a reference API.

There is a discussion in the import maps proposal related to this. https://github.com/WICG/import-maps/issues/79

FWIW I'm not saying that we should or should not have an options argument, more pointing towards motivation for the existing API. Part of the reason it is behind a flag is to give us time to workshop and create something that can be cross platform

>All comments

@ExE-Boss the intent of the api is to make something that could also be implemented / standardized for browser use cases... so it is not using require.resolve as a reference API.

There is a discussion in the import maps proposal related to this. https://github.com/WICG/import-maps/issues/79

FWIW I'm not saying that we should or should not have an options argument, more pointing towards motivation for the existing API. Part of the reason it is behind a flag is to give us time to workshop and create something that can be cross platform

Was this page helpful?
0 / 5 - 0 ratings