DPLA transpiler
raw JSON → 1.0.0 verified Fri May 01 auth: no javascript
DPLA is a custom programming language transpiler that converts DPLA source code into JavaScript. Version 1.0.0 provides core functions for transpilation and execution. It is distributed as a single JavaScript module for use in browsers via CDN. The project is hosted on GitHub with a live demo, but lacks npm distribution, TypeScript definitions, or a dedicated package. Key differentiators: domain-specific language transpiler, minimal API (two functions), and browser-first usage.
Common errors
error Error: Cannot find module 'dpla-lang' ↓
cause Attempting to require or import from npm package name when it is not published to npm.
fix
Replace import source with the correct GitHub CDN URL: import { run } from 'https://cdn.jsdelivr.net/gh/DPLA-S/DPLA/src/index.js'
error Uncaught SyntaxError: The requested module '.../src/index.js' does not provide an export named 'run' ↓
cause Using named import with incorrect export name or the module hasn't loaded properly.
fix
Verify that the import URL is correct and that the module is served with correct MIME type. Use dynamic import if necessary.
error TypeError: transpile is not a function ↓
cause Importing transpile incorrectly, e.g., as a default export or from the wrong path.
fix
Ensure you are using named import: import { transpile } from '<correct url>'
Warnings
gotcha Package not available on npm. Importing from npm will fail. ↓
fix Use the GitHub CDN URL for imports. Do not install via npm.
gotcha No TypeScript definitions provided. TypeScript users will need to declare module types manually. ↓
fix Create a declaration file (.d.ts) for the module.
deprecated The run function may have undefined behavior with certain DPLA constructs; transpile first and review output for production use. ↓
fix Always transpile code and inspect the resulting JavaScript before relying on run() for critical applications.
Install
npm install dpla-lang yarn add dpla-lang pnpm add dpla-lang Imports
- run wrong
const run = require('dpla-lang')correctimport { run } from 'https://cdn.jsdelivr.net/gh/DPLA-S/DPLA/src/index.js' - transpile wrong
import { transpile } from 'dpla-lang'correctimport { transpile } from 'https://cdn.jsdelivr.net/gh/DPLA-S/DPLA/src/index.js' - default export
import * as dpla from 'https://cdn.jsdelivr.net/gh/DPLA-S/DPLA/src/index.js'
Quickstart
import { run, transpile } from 'https://cdn.jsdelivr.net/gh/DPLA-S/DPLA/src/index.js';
// Transpile DPLA code to JavaScript
const dplaCode = 'print "Hello, world!"';
const jsCode = transpile(dplaCode);
console.log('Generated JavaScript:', jsCode);
// Run DPLA code directly
run(dplaCode);
// Example output depends on DPLA language semantics