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

💅 / 🏗 Create new binary for compiler #compiler #35137

Merged
merged 3 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build-system/compile/bundles.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ exports.jsBundles = {
includePolyfills: true,
},
},
'compiler.js': {
srcDir: './src/compiler/',
Copy link
Contributor

Choose a reason for hiding this comment

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

🚲 🏚️ ing time! Do these binaries get served on the CDN?

Copy link
Member Author

@samouri samouri Jul 7, 2021

Choose a reason for hiding this comment

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

I believe so! In this case it would be at https://cdn.ampproject.org/compiler.js as the url.

srcFilename: 'index.js',
destDir: './dist',
minifiedDestDir: './dist',
options: {
minifiedName: 'compiler.js',
},
},
'amp-viewer-host.max.js': {
srcDir: './extensions/amp-viewer-integration/0.1/examples/',
srcFilename: 'amp-viewer-host.js',
Expand Down
3 changes: 3 additions & 0 deletions build-system/tasks/check-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ const TYPE_CHECK_TARGETS = {
srcGlobs: ['src/service/**/*.js'],
warningLevel: 'QUIET',
},
'src-compiler': {
srcGlobs: ['src/compiler/**/*.js'],
},
'src-utils': {
srcGlobs: ['src/utils/**/*.js'],
warningLevel: 'QUIET',
Expand Down
1 change: 1 addition & 0 deletions build-system/tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ async function compileAllJs(options) {
doBuildJs(jsBundles, 'iframe-transport-client-lib.js', options),
doBuildJs(jsBundles, 'recaptcha.js', options),
doBuildJs(jsBundles, 'amp-viewer-host.max.js', options),
doBuildJs(jsBundles, 'compiler.js', options),
doBuildJs(jsBundles, 'video-iframe-integration.js', options),
doBuildJs(jsBundles, 'amp-story-entry-point.js', options),
doBuildJs(jsBundles, 'amp-story-player.js', options),
Expand Down
5 changes: 5 additions & 0 deletions build-system/test-configs/dep-check-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ exports.rules = [
'extensions/amp-mustache/0.1/amp-mustache.js->src/sanitizer.js',
],
},
{
filesMatching: '**/*.js',
mustNotDependOn: 'src/compiler/**/*.js',
allowlist: [],
},
{
filesMatching: '**/*.js',
mustNotDependOn: 'src/purifier/**/*.js',
Expand Down
38 changes: 38 additions & 0 deletions src/compiler/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2021 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Returns the HTML for an AMP Document with eligible components server-rendered.
*
* @param {string} html
* @return {string}
*/
function compileHtml(html) {
return html;
}

/**
* Returns the AST for an AMP Document with eligible components server-rendered.
*
* @param {*} ast
* @return {*}
*/
function compileAst(ast) {
return ast;
}

globalThis.compileHtml = compileHtml;
globalThis.compileAst = compileAst;