How to use the toComputedKey function from babel-types

Find comprehensive JavaScript babel-types.toComputedKey code examples handpicked from public code repositorys.

180
181
182
183
184
185
186
187
188
189
// inline environment variables
walk.simple(originalAst, {
  MemberExpression(node) {
    // Inline environment variables accessed on process.env
    if (matchesPattern(node.object, 'process.env')) {
      let key = babelTypes.toComputedKey(node);
      if (babelTypes.isStringLiteral(key)) {
        let val = babelTypes.valueToNode(process.env[key.value]);
        morph(node, val);
      }
fork icon0
star icon49
watch icon0

+ 3 other calls in file

18
19
20
21
22
23
24
25
26
27

module.exports = {
  MemberExpression(node, asset) {
    // Inline environment variables accessed on process.env
    if (matchesPattern(node.object, 'process.env')) {
      let key = types.toComputedKey(node);
      if (types.isStringLiteral(key)) {
        let val = types.valueToNode(process.env[key.value]);
        morph(node, val);
        asset.isAstDirty = true;
fork icon0
star icon3
watch icon3

+ 13 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)