Wener Notes

transpile

约 1 分钟阅读
标签:编译器

helper

  • tslib
    • 12kB/4kB
  • @swc/helpers
    • 23kB/6kB + tslib
tsconfig.json
{
  "compilerOptions": {
    "importHelpers": true
  }
}
.swcrc
{
  "jsc": {
    "externalHelpers": true
  }
}
bash
# 1041179 bytes -> 573325 bytes reduced 45.00%
find ./lib -type f -name "*.js" -exec stat -c %s {} + | awk '{total += $1} END {print total " bytes"}'

prefix

TypeScript
var require, __filename, __dirname;
{
  const { createRequire } = await import('node:module');
  require ||= createRequire(import.meta.url);
}
{
  const { fileURLToPath } = await import('node:url');
  const { dirname } = await import('node:path');
  __filename ||= fileURLToPath(import.meta.url);
  __dirname ||= dirname(__filename);
}
TypeScript
const __dirname = path.dirname(import.meta.url).replace('file://', '');

import type

TypeScript
import file from './file.txt?raw' with { type: 'text' }
import file from './file.md?raw' with { type: 'text' }

关联信息

反向链接、本文链接的其他页面和外部资料。

References

其他外链2 条
最近更新commit 92ccd87Edit

On this page