官术网_书友最值得收藏!

The import.meta feature

Another new feature, import.meta, is making its way through the TC-39 committee, and is being implemented for Node.js 10.x. It is an object existing within the scope of an ES6 module providing some metadata about the module. See https://github.com/tc39/proposal-import-meta.

A partial implementation, supporting just import.meta.url, has landed in the Node.js source. Its use requires the --harmony-import-meta command-line flag. The content of import.meta.url is a fully qualified file: URL for the current module, such as file:///Users/david/chap10/notes/app.mjs.

Where this becomes important is that ES6 modules do not support the __dirname, __filename, and other global variables used historically in Node.js modules. The __dirname variable is routinely used to read in resource data from files sitting in the package directory. It is intended that for such cases, one parses the directory name out of import.meta.url.

主站蜘蛛池模板: 固原市| 黔西县| 宜川县| 稻城县| 太湖县| 岳池县| 普定县| 台东市| 海丰县| 航空| 读书| 绩溪县| 凤城市| 广平县| 福海县| 堆龙德庆县| 竹北市| 措勤县| 红安县| 特克斯县| 上饶市| 贡嘎县| 大名县| 神池县| 邓州市| 泾阳县| 汉阴县| 科技| 正蓝旗| 赣榆县| 邵武市| 乐平市| 丘北县| 陕西省| 山东省| 金溪县| 翁牛特旗| 常州市| 清涧县| 土默特右旗| 榆树市|