-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Closed
Description
An example of using transform-define for universal configuration is provided, but I have a weird error, which I narrowed down below (run it with babel-node):
// package.json
{
"dependencies": {
"babel-plugin-transform-define": "^1.2.0"
},
"babel": {
"plugins": [
[
"transform-define",
"./config.js"
]
]
}
}// config.js
module.exports = { KEY: 'value' };// index.js
const config = require('./config');
console.log(config.KEY);Somehow next manages to load my app based on the above principle just fine, but the console.log throws when I run the server myself (I'm trying to add integration tests):
TypeError: /Users/sdubois/Documents/relate-debug/index.js: Property property of MemberExpression expected node to be of a type ["Identifier"] but instead got "StringLiteral"
at validate (/usr/local/lib/node_modules/babel-cli/node_modules/babel-types/lib/definitions/index.js:109:13)
at Object.validate (/usr/local/lib/node_modules/babel-cli/node_modules/babel-types/lib/definitions/core.js:412:50)
at Object.validate (/usr/local/lib/node_modules/babel-cli/node_modules/babel-types/lib/index.js:505:9)
at NodePath._replaceWith (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/replacement.js:176:7)
at NodePath.replaceWith (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/replacement.js:160:8)
at replaceAndEvaluateNode (/Users/sdubois/Documents/relate-debug/node_modules/babel-plugin-transform-define/lib/index.js:111:12)
at processNode (/Users/sdubois/Documents/relate-debug/node_modules/babel-plugin-transform-define/lib/index.js:148:5)
at PluginPass.Identifier (/Users/sdubois/Documents/relate-debug/node_modules/babel-plugin-transform-define/lib/index.js:23:9)
at newFn (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:76:18)
Metadata
Metadata
Assignees
Labels
No labels