Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 2.4 KB

jspm.md

File metadata and controls

58 lines (43 loc) · 2.4 KB

JSPM Extension

Task Definitions: None
Template Definitions: 'jspm'
Batcher Defintions: None

Applies the JSPM Generator to an HTML file to populate its import map for module loading using the JSPM Generator htmlGenerate API.

Alternatively, when targetting an .importmap import map file, will output the direct import map JSON.

JSPM Template

Template Options

  • auto-install (Boolean, default: true): Whether to automatically install @babel/core, @babel/cli and the used presets or plugins with npm if not present (using the npm extension). The global npm extension auto-install option will take precedence here if not otherwise set.
  • env (String[], default: ['browser', 'production', 'module']): The list of environment exports conditions to build.
  • es-module-shims (String): Custom URL to use for the ES Module Shims import maps polyfill. Defaults to the latest version on JSPM.
  • integrity (Boolean, default: false): Whether to inject integrity metadata for the module graph (relies on preload tags).
  • preload (Boolean, default: false): Whether to inject modulepreload tags for the static module graph for performance.
  • whitespace (Boolean, default: true): Set to false to serialize the import map without whitespace for minified HTML.
  • ...generate-opts (Dictionary): Any custom JSPM Generator options are supported via object spread.

Example

chompfile.toml

version = 0.1

extensions = ['chomp@0.1:jspm']

# Generate an import map for a browser HTML page
[[task]]
name = 'build:html'
target = 'public/app.html'
dep = 'src/app.html'
template = 'jspm'
[task.template-options]
env = ['browser', 'production', 'module']
preload = true
integrity = true

# Generate an import map for a Deno app
[[task]]
name = 'build:deno-importmap'
target = 'deno.importmap'
dep = 'deno-app.js'
template = 'jspm'
[task.template-options]
env = ['deno', 'production', 'module']

Ejection

Ejection will eject the task with the JS wrapper API for JSPM generator, without the auto install feature.

Roadmap

This extension is actively supported by JSPM and will continue to track JSPM best practices.