Parcel TypeScript Plugin (Parcel 1)

1.0.0 · abandoned · verified Sun Apr 19

parcel-plugin-typescript provides enhanced TypeScript integration for Parcel 1, extending beyond Parcel's native transpiling. Key features include full type checking in a separate process for performance, on-the-fly path mappings based on `tsconfig.json`'s `paths` and `baseUrl` options, and support for custom AST transformers. This plugin aims to offer a comprehensive TypeScript development experience similar to `awesome-typescript-loader` or `ts-loader` in Webpack. The package is currently at version 1.0.0, specifically designed for Parcel 1.x environments. With Parcel 1 no longer actively maintained and superseded by Parcel 2, this plugin is considered unsupported for modern Parcel workflows. There is no ongoing release cadence, and the project repository indicates inactivity since 2019.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates setting up a basic Parcel 1 project with `parcel-plugin-typescript`. It includes `package.json` with dependencies and scripts, `tsconfig.json` configured for path mappings and plugin options, an `index.html` to load the TypeScript, and example TypeScript files (`index.ts` and `utils/helper.ts`) using path aliases.

{
  "name": "parcel-ts-plugin-example",
  "version": "1.0.0",
  "scripts": {
    "start": "parcel src/index.html --open",
    "build": "parcel build src/index.html"
  },
  "devDependencies": {
    "parcel-bundler": "^1.9.0",
    "parcel-plugin-typescript": "^1.0.0",
    "typescript": "^2.4.0"
  }
}
// package.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": "./src",
    "paths": {
      "@utils/*": ["utils/*"]
    }
  },
  "parcelTsPluginOptions": {
    "transpileOnly": false
  }
}
// tsconfig.json

<!-- src/index.html -->
<!DOCTYPE html>
<html>
<head>
  <title>Parcel TS Plugin Example</title>
</head>
<body>
  <h1>Parcel 1 + TypeScript Plugin</h1>
  <div id="app"></div>
  <script src="index.ts"></script>
</body>
</html>

// src/utils/helper.ts
export function getMessage(name: string): string {
  return `Hello from ${name}!`;
}

// src/index.ts
import { getMessage } from '@utils/helper'; // Demonstrates path mapping

const appDiv = document.getElementById('app');
if (appDiv) {
  appDiv.innerHTML = getMessage("Parcel TS Plugin");
}

// Intentionally introduce a type error to show type checking works (if transpileOnly is false)
// const wrongType: number = "this is a string";

console.log(getMessage("console"));

view raw JSON →