Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from plasticine/injectify-loader-integration
Merge injectify-loader and inject-loader
- Loading branch information
Showing
52 changed files
with
4,315 additions
and
743 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
extends: ['airbnb-base'], | ||
rules: { | ||
'import/no-extraneous-dependencies': 'off', | ||
'import/no-webpack-loader-syntax': 'off', | ||
'import/no-unresolved': 'off', | ||
'import/extensions': 'off', | ||
}, | ||
env: { | ||
mocha: true, | ||
jasmine: true | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
node_modules | ||
yarn.lock | ||
flow-typed | ||
# Logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
tmp/ |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
sudo: false | ||
before_install: | ||
- curl -o- -L https://yarnpkg.com/install.sh | bash | ||
- export PATH=$HOME/.yarn/bin:$PATH | ||
language: node_js | ||
cache: yarn | ||
node_js: | ||
- "node" | ||
- "6" | ||
- "5" | ||
- 7 | ||
- 6 | ||
- 5 | ||
- 4 | ||
|
||
cache: yarn | ||
|
||
script: | ||
- npm test | ||
- make lint | ||
- make test | ||
- make build | ||
- make integration-test |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
lint: | ||
yarn run eslint | ||
|
||
test: | ||
yarn run build | ||
yarn run build-test | ||
yarn run test | ||
|
||
integration-test: | ||
./script/integration_test | ||
|
||
build: | ||
yarn run build | ||
mkdir -p ./dist | ||
cp -f ./tmp/index.js ./dist/index.js | ||
cp -f ./tmp/index.js.map ./dist/index.js.map |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
a() { | ||
return 'a - original'; | ||
}, | ||
require() { | ||
return 'require method in a.js'; | ||
}, | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
define((require) => { // eslint-disable-line no-undef | ||
const a = require('./a.js'); | ||
const b = require('./b.js'); | ||
|
||
return { | ||
getA() { | ||
return a.a(); | ||
}, | ||
|
||
getB() { | ||
return b(); | ||
}, | ||
|
||
callRequireMethod() { | ||
return a.require(); | ||
}, | ||
}; | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function b() { | ||
return 'b - original'; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const a = require('./a.js'); | ||
const b = require('./b.js'); | ||
|
||
module.exports = { | ||
getA() { | ||
return a.a(); | ||
}, | ||
|
||
getB() { | ||
return b(); | ||
}, | ||
|
||
callRequireMethod() { | ||
return a.require(); | ||
}, | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import a, { a as methodA } from './a.js'; | ||
import b from './b.js'; | ||
|
||
export function getA() { | ||
return methodA(); | ||
} | ||
|
||
export function getB() { | ||
return b(); | ||
} | ||
|
||
export function callRequireMethod() { | ||
return a.require(); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* eslint-disable global-require */ | ||
|
||
const assert = require('assert'); | ||
|
||
const MODULE_A_STUB = { | ||
a() { | ||
return 'a - stubbed'; | ||
}, | ||
}; | ||
|
||
const MODULE_B_STUB = () => 'b - stubbed'; | ||
|
||
describe('inject-loader', () => { | ||
const injectors = [ | ||
{ moduleType: 'commonjs', moduleInjector: require('self!./modules/commonjs.js') }, | ||
{ moduleType: 'amd', moduleInjector: require('self!./modules/amd.js') }, | ||
{ moduleType: 'es6', moduleInjector: require('self!./modules/es6.js') }, | ||
]; | ||
|
||
injectors.forEach((injector) => { | ||
describe(`${injector.moduleType} modules`, () => { | ||
it('works when no injections were provided', () => { | ||
const module = injector.moduleInjector(); | ||
|
||
assert.equal(module.getA(), 'a - original'); | ||
assert.equal(module.getB(), 'b - original'); | ||
}); | ||
|
||
it('works when one injection was provided', () => { | ||
const module = injector.moduleInjector({ | ||
'./a.js': MODULE_A_STUB, | ||
}); | ||
|
||
assert.equal(module.getA(), 'a - stubbed'); | ||
assert.equal(module.getB(), 'b - original'); | ||
}); | ||
|
||
it('works when multiple injections were provided', () => { | ||
const module = injector.moduleInjector({ | ||
'./a.js': MODULE_A_STUB, | ||
'./b.js': MODULE_B_STUB, | ||
}); | ||
|
||
assert.equal(module.getA(), 'a - stubbed'); | ||
assert.equal(module.getB(), 'b - stubbed'); | ||
}); | ||
|
||
it('throws an error when invalid dependencies are provided', () => { | ||
const injectInvalidDependencies = () => { | ||
injector.moduleInjector({ | ||
'./b.js': null, | ||
'./c.js': null, | ||
}); | ||
}; | ||
|
||
assert.throws(injectInvalidDependencies, /The following injections are invalid:\n- \.\/c\.js/); | ||
}); | ||
|
||
it('does not break someObject.require calls', () => { | ||
const module = injector.moduleInjector(); | ||
|
||
assert.equal(module.callRequireMethod(), 'require method in a.js'); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.