Skip to content

import.meta: (Stage 3) #10

@babel-bot

Description

@babel-bot

Original issue submitted by @hzoo in babel/babel#5832

Original issue submitted by @hzoo in babel/babylon#539

import.meta for stage 2 (Domenic Denicola) (@domenic)

Info

Proposed at TC39 Meeting: May 2017
Spec Repo: https://github.com/tc39/proposal-import-meta
Spec Text: https://tc39.github.io/proposal-import-meta/
Moved to Stage 3 at the Sept 2017 meeting

Example

(async () => {
  const response = await fetch(new URL("../hamsters.jpg", import.meta.url));
  const blob = await response.blob();

  const size = import.meta.scriptElement.dataset.size || 300;

  const image = new Image();
  image.src = URL.createObjectURL(blob);
  image.width = image.height = size;

  document.body.appendChild(image);
})();

Parsing

Transform

  • Not sure, maybe webpack should handle? Or in node?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions