Web-based Source Map validator
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
.travis
client
server
.eslintignore
.eslintrc.json
.gitignore
.travis.yml
LICENSE
Makefile
README.md
package-lock.json
package.json

README.md

sourcemaps.io Build Status

A re-write of sourcemap-validator using React, Node, and Google Cloud Functions.

image

sourcemaps.io is a web application that takes a URL for a target transpiled/minified JavaScript file (e.g. https://example.com/js/app.min.js), and verifies:

  • sourceMappingURL or [X-]SourceMap header is present
  • Both the transpiled/minified file and source map file are reachable via HTTP
  • The resolved source map is valid JSON, and parses using Mozilla's source-map library
  • Lines and columns line up as expected
  • ... and more, see tests

Development

Run tests

make test

Run a local server for client (React) development

make client-server

Run a local server for backend development

A local development server will serve the validation function for development.

make backend-server

NOTE: Right now the local server still writes JSON reports to a production Google Cloud Storage bucket. You must have the following shell variables exported (see Deploy to Google Cloud Platform below).

export GCLOUD_PROJECT=myproject-server
export GCLOUD_DATA_BUCKET=myproject-reports
make backend-server

Deploy to Google Cloud Platform

This repository is already configured to automatically deploy to http://v2.sourcemaps.io. But for posterity, this documents how to configure your own Google Cloud deployment environment and how to use the deploy scripts.

Configure your Project

  1. Create a new project in Google Cloud Platform, e.g. myproject
  2. Enable Cloud Functions (currently in beta)
  3. Create 3 buckets in Cloud Storage, for:
    1. staging the cloud function (e.g. myproject-server)
    2. storing report data (e.g. myproject-reports)
    3. storing static web content (e.g. myproject-web)

Deploying

First authenticate with Google Cloud Platform:

gcloud auth login

Then initiate the deploy:

export GCLOUD_PROJECT=myproject
export GCLOUD_APP_BUCKET=myproject-server
export GCLOUD_DATA_BUCKET=myproject-reports
export GCLOUD_WWW_BUCKET=myproject-web
make deploy

NOTE: The deploy script will set READ permissions on GCLOUD_DATA_BUCKET and GCLOUD_WWW_BUCKET.

Invoking the Serverless Function

The deployed serverless function is publicly accessible over HTTP. To trigger the function manually, do:

$ curl -X GET "https://${region}-${GCLOUD_PROJECT}.cloudfunctions.net/validateSourceFile?url=http://example.org/static/app.js"