- Node.js Web Development
- David Herron
- 136字
- 2021-06-25 21:54:05
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.
- C++面向?qū)ο蟪绦蛟O(shè)計(jì)(第三版)
- 少兒人工智能趣味入門:Scratch 3.0動(dòng)畫與游戲編程
- Git Version Control Cookbook
- ReSharper Essentials
- Practical UX Design
- PHP+MySQL網(wǎng)站開(kāi)發(fā)技術(shù)項(xiàng)目式教程(第2版)
- Cassandra Design Patterns(Second Edition)
- Object-Oriented JavaScript(Second Edition)
- Visual Basic程序設(shè)計(jì)習(xí)題解答與上機(jī)指導(dǎo)
- Terraform:多云、混合云環(huán)境下實(shí)現(xiàn)基礎(chǔ)設(shè)施即代碼(第2版)
- Python機(jī)器學(xué)習(xí)算法與應(yīng)用
- JavaScript+jQuery網(wǎng)頁(yè)特效設(shè)計(jì)任務(wù)驅(qū)動(dòng)教程
- 軟件工程基礎(chǔ)與實(shí)訓(xùn)教程
- 新印象:解構(gòu)UI界面設(shè)計(jì)
- Visual FoxPro 6.0程序設(shè)計(jì)