Last active
August 1, 2016 12:36
-
-
Save ronkot/2babe4b777d7bcb4053b9747d9c59346 to your computer and use it in GitHub Desktop.
babel-plugin-rewire problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"presets": ["es2015", "es2015-node4", "async-to-bluebird"], | |
"env": { | |
"test": { | |
"plugins": ["babel-plugin-rewire"] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "api", | |
"version": "0.0.1", | |
"private": true, | |
"description": "New Swagger API Project", | |
"keywords": [], | |
"author": "", | |
"license": "", | |
"main": "app.js", | |
"dependencies": { | |
"babel-core": "^6.10.4", | |
"babel-eslint": "^4.1.6", | |
"babel-polyfill": "^6.3.14", | |
"babel-preset-async-to-bluebird": "^1.0.0", | |
"babel-preset-es2015": "^6.3.13", | |
"babel-preset-es2015-node4": "^2.0.2", | |
"babel-register": "^6.3.13", | |
"bluebird": "^3.1.1", | |
"body-parser": "^1.15.1" | |
}, | |
"devDependencies": { | |
"babel-plugin-rewire": "^1.0.0-rc-3", | |
"mocha": "^2.5.3", | |
"should": "^7.1.0" | |
}, | |
"scripts": { | |
"test": "NODE_ENV=test mocha --compilers js:babel-register --require babel-polyfill --require should" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const should = require('should') | |
try { | |
console.log('should through variable: ', should) | |
} catch (error) { | |
console.log(error) | |
} | |
console.log('should through require: ', require('should')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason the
should
library cannot be required to variable.To reproduce, run:
npm install && npm test
To fix the import error (but break rewire functionality), comment out the rewire plugin from
.babelrc