Skip to content

Commit

Permalink
use of rollup-plugin-inject to avoid expecting three to provide a def…
Browse files Browse the repository at this point in the history
…ault export when importing non-module three examples.

see issue videojs#50
  • Loading branch information
developpeur2000 committed Feb 19, 2018
1 parent 343cd72 commit 28203a7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"rollup": "^0.50",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-inject": "^2.0.0",
"rollup-plugin-json": "^2.1.1",
"rollup-plugin-multi-entry": "^2.0.1",
"rollup-plugin-node-resolve": "^3.0.0",
Expand Down
5 changes: 5 additions & 0 deletions scripts/modules.rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import json from 'rollup-plugin-json';
import replace from './rollup-replace';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import inject from 'rollup-plugin-inject';

export default {
name: 'videojsVr',
Expand Down Expand Up @@ -58,6 +59,10 @@ export default {
'external-helpers',
'transform-object-assign'
]
}),
inject({
include: ['node_modules/three/examples/js/**'],
THREE: ['three', '*']
})
]
};
6 changes: 3 additions & 3 deletions scripts/rollup-replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default function(options) {
return replace(Object.assign({
'include': ['node_modules/three/examples/js/**'],
'delimiters': ['', ''],
'THREE.VRControls =': "var THREE = require('three');var VRControls;\nmodule.exports = VRControls =",
'THREE.VRControls =': 'var VRControls;\nmodule.exports = VRControls =',
'THREE.VRControls': 'VRControls',

'THREE.VREffect =': "var THREE = require('three');var VREffect;\nmodule.exports = VREffect =",
'THREE.VREffect =': 'var VREffect;\nmodule.exports = VREffect =',
'THREE.VREffect': 'VREffect',

'THREE.OrbitControls =': "var THREE = require('three');var OrbitControls;\nmodule.exports = OrbitControls =",
'THREE.OrbitControls =': 'var OrbitControls;\nmodule.exports = OrbitControls =',
'THREE.OrbitControls': 'OrbitControls'
}, options || {}));
}
Expand Down

0 comments on commit 28203a7

Please sign in to comment.