1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

Remove __pdfjsdev_webpack__, use webpack options

`__pdfjsdev_webpack__` was used to skip evaluating part of an AST,
in order to not mangle some `require` symbols.
This commit removes `__pdfjsdev_webpack__`, and:

- Uses `__non_webpack_require__` when one wants the output to
  contain `require` instead of `__webpack_require__`.
- Adds options to the webpack config to prevent "polyfills" for
  some Node.js-specific APIs to be added.
- Use `// eslint-disable-next-line no-undef` instead of `/* globals ... */`
  for variables that are not meant to be used globally.
This commit is contained in:
Rob Wu 2017-07-09 15:19:16 +02:00
parent 7b4887dd21
commit 742ed3d1c9
5 changed files with 52 additions and 80 deletions

View file

@ -12,19 +12,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals module, __pdfjsdev_webpack__ */
/* globals module, __non_webpack_require__ */
'use strict';
var pdfjsLib;
// The if below protected by __pdfjsdev_webpack__ check from webpack parsing.
if (typeof __pdfjsdev_webpack__ === 'undefined') {
if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
pdfjsLib = window['pdfjs-dist/build/pdf'];
} else if (typeof require === 'function') {
pdfjsLib = require('../build/pdf.js');
} else {
throw new Error('Neither `require` nor `window` found');
}
if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
pdfjsLib = window['pdfjs-dist/build/pdf'];
} else if (typeof __non_webpack_require__ === 'function') {
pdfjsLib = __non_webpack_require__('../build/pdf.js');
} else {
throw new Error('Neither `require` nor `window` found');
}
module.exports = pdfjsLib;