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

fix gulp integration and server so that it can work with mjs files #30292

Merged
merged 34 commits into from
Oct 14, 2020

Conversation

erwinmombay
Copy link
Member

@erwinmombay erwinmombay commented Sep 18, 2020

To make gulp integration work cleanly with mjs files we transform the fixtures/* html files to the module script during gulp integration --esm.

fixes:

  • make it so that src transformation only happens strictly in scripts/cript-transform.ts
  • fixed ordering of module/nomodule pair. currently it would be contiguous nomodules followed by contiguous module scripts.
  • skip over script tags that are of type="application/json"

feature adds:

  • added looseScriptSrcCheck to allow for non cdn domains. This will allow us to transition from the bad fixture files (with bad src strings that have no domain and is an implicit localhost) to having all html files be valid AMP HTML by default.

Related PR(s):
#30378 (add mjs server routes)
#28336 (turn on esm tests)

@google-cla google-cla bot added the cla: yes label Sep 18, 2020
@erwinmombay erwinmombay force-pushed the fix-posthtml-transformers branch 4 times, most recently from 0f5ae48 to ce5d37c Compare September 23, 2020 17:45
@erwinmombay erwinmombay changed the title make it so that src transformation only happens strictly in scripts/cript-transform.ts fix gulp integration and server so that it can work with mjs files Sep 23, 2020
@erwinmombay erwinmombay force-pushed the fix-posthtml-transformers branch 3 times, most recently from c40812e to d3751c2 Compare September 24, 2020 16:25
@erwinmombay
Copy link
Member Author

@caroqliu adding you as i would love to get typescript feedback!

Copy link
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

Thanks for thinking of me to do a review, left a few comments

build-system/server/new-server/transforms/transform.ts Outdated Show resolved Hide resolved
build-system/tasks/integration.js Outdated Show resolved Hide resolved
test/fixtures/amp-cupcake-ad.html Outdated Show resolved Hide resolved
Copy link
Contributor

@kristoferbaxter kristoferbaxter left a comment

Choose a reason for hiding this comment

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

Agree with a lot of the comments left. Thanks for getting this done!

@erwinmombay erwinmombay merged commit 73b3f0e into ampproject:master Oct 14, 2020
Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

A couple comments below. LGTM after they are addressed.

Comment on lines +26 to +28
return `node .\\node_modules\\typescript\\lib\\tsc.js -p ${SERVER_TRANSFORM_PATH.split(
'/'
).join(pathModule.sep)}${pathModule.sep}tsconfig.json`;
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 it might be possible to replace this split / join block with a path.posix method.

/cc @samouri, who has experience with this, and the vagaries of Windows.

if (result.status != 0) {
const err = new Error('Could not build AMP Dev Server');
err.showStack = false;
err.showStack = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason this was false in the first place was because the message in err contained the useful info, while the stack contained a very verbose and mostly useless nodejs callstack. Has any of this changed? (If yes, you can delete this line, since the default is true. If not, I'd suggest reverting this line.)

ed-bird pushed a commit to ed-bird/amphtml that referenced this pull request Dec 10, 2020
…mpproject#30292)

* make it so that src transformation only happens strictly in scripts/script-transform.ts

each module should do 1 thing and 1 thing only. currently the module
transformer also did a src/url transformation. this caused weird
mismatches when they are ran together.

- added looseScriptSrcCheck to allow for non cdn domains. This will
  allow us to transition from the bad fixture files to having all html
  files be valid AMP HTML by default.

* temp

* temp

* fix imports

* add transform back to integration

* fix html

* fix integration

* temp

* temp

* make transformers have a loose mode to be more forgiving on script src

* add more tests and fix bug for extention retention

* allow for mjs files to be served by the test server

* add glob to load mjs files in karma server

* lint fixes

* lint html

* break up this PR

* fix bad error formatting

* apply recs

* Update build-system/server/new-server/transforms/transform.ts

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* Update build-system/server/new-server/transforms/utilities/option-set.ts

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* fix other locations of "FORTESTING"

* fix esm and non esm tests to be green

* use writeFileSync instead of async method. seems to be a race

* guarantee directory exists first

* fix windows issues

* skip failing IE test temporarily

* applied recs

* apply more recs

* temporarily read from testing version.txt

* temp "only"

* dont reroute to max json files

* change error to warning

* fix max builds and integration tests against max files

* revert testing changes. we'll separete it into its own PR

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants