Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces RequireJS to SystemJS. #8050

Merged
merged 1 commit into from Feb 27, 2017
Merged

Conversation

yurydelendik
Copy link
Contributor

@yurydelendik yurydelendik commented Feb 9, 2017

Removes RequireJS dependency since it will be hard to adapt ES6 module transpilers. It will be easier with SystemJS. Questions to resolve:

  • Central configuration (vs SystemJS.config in multiple places)
  • Dependency on Promise for legacy browsers (increase bar or move Promise polyfill to compatibility.js), e.g. we use that in some examples.

@yurydelendik yurydelendik added this to In Progress in ES6 modules Feb 9, 2017
@yurydelendik yurydelendik changed the title [WIP] Replaces RequireJS to SystemJS. Replaces RequireJS to SystemJS. Feb 9, 2017
@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Feb 9, 2017

Dependency on Promise for legacy browsers (increase bar or move Promise polyfill to compatibility.js), e.g. we use that in some examples.

Personally I feel that support for older browsers are now seriously holding us back from using many of the really nice new features in ES6, and I would wholeheartedly support increasing the minimum requirements for using PDF.js.

My suggestion is that version 1.7.225 (the current pre-release) should be the last version with support for pre-ES6 browsers, and that going forward only ES6 compatible browsers/environments will be supported.

Such a requirement would mean that most, if not all, compatibility code could be removed; furthermore it'd also reduce the support burden since we'd no longer need to add any new compatibility hacks (which would be nice, given the limited number of regular PDF.js contributors).
Obviously such a decision would need to be communicated publicly not just in the Wiki/README, but also on the mailing list/Twitter first. However I really think that this is the way forward here!

@brendandahl
Copy link
Contributor

Personally I feel that support for older browsers are now seriously holding us back from using many of the really nice new features in ES6, and I would wholeheartedly support increasing the minimum requirements for using PDF.js.

We can use a transpiler (like babel) to support old browsers and still have all the shiny new stuff.

@yurydelendik
Copy link
Contributor Author

/botio test

require(['pdfjs/display/api', 'pdfjs/display/svg', 'pdfjs/display/global'],
function (api, svg, global) {
// In production, the bundled pdf.js shall be used instead of SystemJS.
SystemJS.config({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this now that we have systemjs.config.js that seems to define this correctly? Compare to examples/helloworld/hello.js that also doesn't have this.

@@ -15,21 +15,20 @@

'use strict';

if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change necessary? Shouldn't this block be moved to compatibility.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed only for requirejs (and probably for SystemJS as well) -- our tests were failing without it. Since we are not using src/worker_loader.js in the production anyway, I decided to remove the pre-processor from here.

@@ -0,0 +1,45 @@
/* Copyright 2012 Mozilla Foundation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this to 2017.

if (typeof document !== 'undefined') {
baseLocation = new URL('./', document.currentScript.src);
} else if (typeof location !== 'undefined') {
// Probably worker -- walking subfolders until we will reach root.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: one space too much here in the indentation

SystemJS.import('pdfjs/display/global'),
SystemJS.import('pdfjs/shared/util')])
.then(function (modules) {
var pdfjsSharedUtil = modules[4];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get rid of this intermediate variable and make the next line window.pdfjsSharedUtil = modules[4]; directly. The intermediate variable doesn't provide more clarity about what's happening.

'pdfjs-test': '..'}});
require(['pdfjs/display/global', 'pdfjs-test/unit/annotation_spec',
Promise.all([
'pdfjs/display/global', 'pdfjs-test/unit/annotation_spec',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent with the rest of the files. I'd prefer if we keep the same indentation as we do for other files here as well, i.e., indent with two spaces (I don't mind the diff being a few lines larger).

web/viewer.js Outdated
Promise.all([SystemJS.import('pdfjs-web/app'),
SystemJS.import('pdfjs-web/pdf_print_service')])
.then(function (modules) {
var web = modules[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this variable app instead? It's a bit confusing because web for me refers to the entire web folder, whereas app is clearly only app.js.

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/d1d29810130162e/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/d1d29810130162e/output.txt

Total script time: 2.16 mins

Published

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/199f213dbd9f162/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 1

Live output at: http://54.215.176.217:8877/296868ca9d08d8e/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/296868ca9d08d8e/output.txt

Total script time: 22.10 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/199f213dbd9f162/output.txt

Total script time: 29.85 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij timvandermeij merged commit 25f772a into mozilla:master Feb 27, 2017
@timvandermeij
Copy link
Contributor

Thank you for working on this!

@timvandermeij timvandermeij moved this from In progress to Done in ES6 modules Feb 27, 2017
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants