Initial commit of working RSS Aggregator build
This commit is contained in:
1 parent
ea3a2ca53e
commit
7ac2f6e384
4962 files changed
+1032666
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
import type * as swcWasm from '@swc/wasm';
|
||||
import type { CreateTranspilerOptions, Transpiler } from './types';
|
||||
export interface SwcTranspilerOptions extends CreateTranspilerOptions {
|
||||
/**
|
||||
* swc compiler to use for compilation
|
||||
* Set to '@swc/wasm' to use swc's WASM compiler
|
||||
* Default: '@swc/core', falling back to '@swc/wasm'
|
||||
*/
|
||||
swc?: string | typeof swcWasm;
|
||||
}
|
||||
export declare function create(createOptions: SwcTranspilerOptions): Transpiler;
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createSwcOptions = exports.targetMapping = exports.create = void 0;
|
||||
const ts_internals_1 = require("../ts-internals");
|
||||
function create(createOptions) {
|
||||
const { swc, service: { config, projectLocalResolveHelper }, transpilerConfigLocalResolveHelper, nodeModuleEmitKind, } = createOptions;
|
||||
// Load swc compiler
|
||||
let swcInstance;
|
||||
// Used later in diagnostics; merely needs to be human-readable.
|
||||
let swcDepName = 'swc';
|
||||
if (typeof swc === 'string') {
|
||||
swcDepName = swc;
|
||||
swcInstance = require(transpilerConfigLocalResolveHelper(swc, true));
|
||||
}
|
||||
else if (swc == null) {
|
||||
let swcResolved;
|
||||
try {
|
||||
swcDepName = '@swc/core';
|
||||
swcResolved = transpilerConfigLocalResolveHelper(swcDepName, true);
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
swcDepName = '@swc/wasm';
|
||||
swcResolved = transpilerConfigLocalResolveHelper(swcDepName, true);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error('swc compiler requires either @swc/core or @swc/wasm to be installed as a dependency. See https://typestrong.org/ts-node/docs/transpilers');
|
||||
}
|
||||
}
|
||||
swcInstance = require(swcResolved);
|
||||
}
|
||||
else {
|
||||
swcInstance = swc;
|
||||
}
|
||||
// Prepare SWC options derived from typescript compiler options
|
||||
const { nonTsxOptions, tsxOptions } = createSwcOptions(config.options, nodeModuleEmitKind, swcInstance, swcDepName);
|
||||
const transpile = (input, transpileOptions) => {
|
||||
const { fileName } = transpileOptions;
|
||||
const swcOptions = fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? tsxOptions : nonTsxOptions;
|
||||
const { code, map } = swcInstance.transformSync(input, {
|
||||
...swcOptions,
|
||||
filename: fileName,
|
||||
});
|
||||
return { outputText: code, sourceMapText: map };
|
||||
};
|
||||
return {
|
||||
transpile,
|
||||
};
|
||||
}
|
||||
exports.create = create;
|
||||
/** @internal */
|
||||
exports.targetMapping = new Map();
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES3 */ 0, 'es3');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES5 */ 1, 'es5');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2015 */ 2, 'es2015');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2016 */ 3, 'es2016');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2017 */ 4, 'es2017');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2018 */ 5, 'es2018');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2019 */ 6, 'es2019');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2020 */ 7, 'es2020');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2021 */ 8, 'es2021');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ES2022 */ 9, 'es2022');
|
||||
exports.targetMapping.set(/* ts.ScriptTarget.ESNext */ 99, 'esnext');
|
||||
/**
|
||||
* @internal
|
||||
* We use this list to downgrade to a prior target when we probe swc to detect if it supports a particular target
|
||||
*/
|
||||
const swcTargets = [
|
||||
'es3',
|
||||
'es5',
|
||||
'es2015',
|
||||
'es2016',
|
||||
'es2017',
|
||||
'es2018',
|
||||
'es2019',
|
||||
'es2020',
|
||||
'es2021',
|
||||
'es2022',
|
||||
'esnext',
|
||||
];
|
||||
const ModuleKind = {
|
||||
None: 0,
|
||||
CommonJS: 1,
|
||||
AMD: 2,
|
||||
UMD: 3,
|
||||
System: 4,
|
||||
ES2015: 5,
|
||||
ES2020: 6,
|
||||
ESNext: 99,
|
||||
Node16: 100,
|
||||
NodeNext: 199,
|
||||
};
|
||||
const JsxEmit = {
|
||||
ReactJSX: /* ts.JsxEmit.ReactJSX */ 4,
|
||||
ReactJSXDev: /* ts.JsxEmit.ReactJSXDev */ 5,
|
||||
};
|
||||
/**
|
||||
* Prepare SWC options derived from typescript compiler options.
|
||||
* @internal exported for testing
|
||||
*/
|
||||
function createSwcOptions(compilerOptions, nodeModuleEmitKind, swcInstance, swcDepName) {
|
||||
var _a;
|
||||
const { esModuleInterop, sourceMap, importHelpers, experimentalDecorators, emitDecoratorMetadata, target, module, jsx, jsxFactory, jsxFragmentFactory, strict, alwaysStrict, noImplicitUseStrict, jsxImportSource, } = compilerOptions;
|
||||
let swcTarget = (_a = exports.targetMapping.get(target)) !== null && _a !== void 0 ? _a : 'es3';
|
||||
// Downgrade to lower target if swc does not support the selected target.
|
||||
// Perhaps project has an older version of swc.
|
||||
// TODO cache the results of this; slightly faster
|
||||
let swcTargetIndex = swcTargets.indexOf(swcTarget);
|
||||
for (; swcTargetIndex >= 0; swcTargetIndex--) {
|
||||
try {
|
||||
swcInstance.transformSync('', {
|
||||
jsc: { target: swcTargets[swcTargetIndex] },
|
||||
});
|
||||
break;
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
swcTarget = swcTargets[swcTargetIndex];
|
||||
const keepClassNames = target >= /* ts.ScriptTarget.ES2016 */ 3;
|
||||
const isNodeModuleKind = module === ModuleKind.Node16 || module === ModuleKind.NodeNext;
|
||||
// swc only supports these 4x module options [MUST_UPDATE_FOR_NEW_MODULEKIND]
|
||||
const moduleType = module === ModuleKind.CommonJS
|
||||
? 'commonjs'
|
||||
: module === ModuleKind.AMD
|
||||
? 'amd'
|
||||
: module === ModuleKind.UMD
|
||||
? 'umd'
|
||||
: isNodeModuleKind && nodeModuleEmitKind === 'nodecjs'
|
||||
? 'commonjs'
|
||||
: isNodeModuleKind && nodeModuleEmitKind === 'nodeesm'
|
||||
? 'es6'
|
||||
: 'es6';
|
||||
// In swc:
|
||||
// strictMode means `"use strict"` is *always* emitted for non-ES module, *never* for ES module where it is assumed it can be omitted.
|
||||
// (this assumption is invalid, but that's the way swc behaves)
|
||||
// tsc is a bit more complex:
|
||||
// alwaysStrict will force emitting it always unless `import`/`export` syntax is emitted which implies it per the JS spec.
|
||||
// if not alwaysStrict, will emit implicitly whenever module target is non-ES *and* transformed module syntax is emitted.
|
||||
// For node, best option is to assume that all scripts are modules (commonjs or esm) and thus should get tsc's implicit strict behavior.
|
||||
// Always set strictMode, *unless* alwaysStrict is disabled and noImplicitUseStrict is enabled
|
||||
const strictMode =
|
||||
// if `alwaysStrict` is disabled, remembering that `strict` defaults `alwaysStrict` to true
|
||||
(alwaysStrict === false || (alwaysStrict !== true && strict !== true)) &&
|
||||
// if noImplicitUseStrict is enabled
|
||||
noImplicitUseStrict === true
|
||||
? false
|
||||
: true;
|
||||
const jsxRuntime = jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev ? 'automatic' : undefined;
|
||||
const jsxDevelopment = jsx === JsxEmit.ReactJSXDev ? true : undefined;
|
||||
const useDefineForClassFields = (0, ts_internals_1.getUseDefineForClassFields)(compilerOptions);
|
||||
const nonTsxOptions = createVariant(false);
|
||||
const tsxOptions = createVariant(true);
|
||||
return { nonTsxOptions, tsxOptions };
|
||||
function createVariant(isTsx) {
|
||||
const swcOptions = {
|
||||
sourceMaps: sourceMap,
|
||||
// isModule: true,
|
||||
module: moduleType
|
||||
? {
|
||||
type: moduleType,
|
||||
...(moduleType === 'amd' || moduleType === 'commonjs' || moduleType === 'umd'
|
||||
? {
|
||||
noInterop: !esModuleInterop,
|
||||
strictMode,
|
||||
// For NodeNext and Node12, emit as CJS but do not transform dynamic imports
|
||||
ignoreDynamic: nodeModuleEmitKind === 'nodecjs',
|
||||
}
|
||||
: {}),
|
||||
}
|
||||
: undefined,
|
||||
swcrc: false,
|
||||
jsc: {
|
||||
externalHelpers: importHelpers,
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
tsx: isTsx,
|
||||
decorators: experimentalDecorators,
|
||||
dynamicImport: true,
|
||||
importAssertions: true,
|
||||
},
|
||||
target: swcTarget,
|
||||
transform: {
|
||||
decoratorMetadata: emitDecoratorMetadata,
|
||||
legacyDecorator: true,
|
||||
react: {
|
||||
throwIfNamespace: false,
|
||||
development: jsxDevelopment,
|
||||
useBuiltins: false,
|
||||
pragma: jsxFactory,
|
||||
pragmaFrag: jsxFragmentFactory,
|
||||
runtime: jsxRuntime,
|
||||
importSource: jsxImportSource,
|
||||
},
|
||||
useDefineForClassFields,
|
||||
},
|
||||
keepClassNames,
|
||||
experimental: {
|
||||
keepImportAttributes: true,
|
||||
emitAssertForImportAttributes: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
// Throw a helpful error if swc version is old, for example, if it rejects `ignoreDynamic`
|
||||
try {
|
||||
swcInstance.transformSync('', swcOptions);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(`${swcDepName} threw an error when attempting to validate swc compiler options.\n` +
|
||||
'You may be using an old version of swc which does not support the options used by ts-node.\n' +
|
||||
'Try upgrading to the latest version of swc.\n' +
|
||||
'Error message from swc:\n' +
|
||||
(e === null || e === void 0 ? void 0 : e.message));
|
||||
}
|
||||
return swcOptions;
|
||||
}
|
||||
}
|
||||
exports.createSwcOptions = createSwcOptions;
|
||||
//# sourceMappingURL=swc.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"swc.js","sourceRoot":"","sources":["../../src/transpilers/swc.ts"],"names":[],"mappings":";;;AAKA,kDAA6D;AAY7D,SAAgB,MAAM,CAAC,aAAmC;IACxD,MAAM,EACJ,GAAG,EACH,OAAO,EAAE,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O,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3G,MAAM,uBAAuB,GAAG,IAAA,yCAA0B,EAAC,eAAe,CAAC,CAAC;IAE5E,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;IAErC,SAAS,aAAa,CAAC,KAAc;QACnC,MAAM,UAAU,GAAqB;YACnC,UAAU,EAAE,SAAS;YACrB,kBAAkB;YAClB,MAAM,EAAE,UAAU;gBAChB,CAAC,CAAC;oBACE,IAAI,EAAE,UAAU;oBAChB,GAAG,CAAC,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,UAAU,IAAI,UAAU,KAAK,KAAK;wBAC3E,CAAC,CAAC;4BACE,SAAS,EAAE,CAAC,eAAe;4BAC3B,UAAU;4BACV,4EAA4E;4BAC5E,aAAa,EAAE,kBAAkB,KAAK,SAAS;yBAChD;wBACH,CAAC,CAAC,EAAE,CAAC;iBACR;gBACH,CAAC,CAAC,SAAS;YACb,KAAK,ELine truncated
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import type * as ts from 'typescript';
|
||||
import type { Service } from '../index';
|
||||
/**
|
||||
* Third-party transpilers are implemented as a CommonJS module with a
|
||||
* named export "create"
|
||||
*
|
||||
* @category Transpiler
|
||||
*/
|
||||
export interface TranspilerModule {
|
||||
create: TranspilerFactory;
|
||||
}
|
||||
/**
|
||||
* Called by ts-node to create a custom transpiler.
|
||||
*
|
||||
* @category Transpiler
|
||||
*/
|
||||
export declare type TranspilerFactory = (options: CreateTranspilerOptions) => Transpiler;
|
||||
/** @category Transpiler */
|
||||
export interface CreateTranspilerOptions {
|
||||
service: Pick<Service, Extract<'config' | 'options' | 'projectLocalResolveHelper', keyof Service>>;
|
||||
}
|
||||
/** @category Transpiler */
|
||||
export interface Transpiler {
|
||||
transpile(input: string, options: TranspileOptions): TranspileOutput;
|
||||
}
|
||||
/** @category Transpiler */
|
||||
export interface TranspileOptions {
|
||||
fileName: string;
|
||||
}
|
||||
/** @category Transpiler */
|
||||
export interface TranspileOutput {
|
||||
outputText: string;
|
||||
diagnostics?: ts.Diagnostic[];
|
||||
sourceMapText?: string;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/transpilers/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as ts from 'typescript';\nimport type { NodeModuleEmitKind, Service } from '../index';\nimport type { ProjectLocalResolveHelper } from '../util';\n\n/**\n * Third-party transpilers are implemented as a CommonJS module with a\n * named export \"create\"\n *\n * @category Transpiler\n */\nexport interface TranspilerModule {\n create: TranspilerFactory;\n}\n/**\n * Called by ts-node to create a custom transpiler.\n *\n * @category Transpiler\n */\nexport type TranspilerFactory = (\n options: CreateTranspilerOptions\n) => Transpiler;\n/** @category Transpiler */\nexport interface CreateTranspilerOptions {\n // TODO this is confusing because its only a partial Service. Rename?\n // Careful: must avoid stripInternal breakage by guarding with Extract<>\n service: Pick<\n Service,\n Extract<'config' | 'options' | 'projectLocalResolveHelper', keyof Service>\n >;\n /**\n * If `\"transpiler\"` option is declared in an \"extends\" tsconfig, this path might be different than\n * the `projectLocalResolveHelper`\n *\n * @internal\n */\n transpilerConfigLocalResolveHelper: ProjectLocalResolveHelper;\n /**\n * When using `module: nodenext` or `module: node12`, there are two possible styles of emit:\n * - CommonJS with dynamic imports preserved (not transformed into `require()` calls)\n * - ECMAScript modules with `import foo = require()` transformed into `require = createRequire(); const foo = require()`\n * @internal\n */\n nodeModuleEmitKind?: NodeModuleEmitKind;\n}\n/** @category Transpiler */\nexport interface Transpiler {\n // TODOs\n // Create spec for returning diagnostics? Currently transpilers are allowed to\n // throw an error but that's it.\n transpile(input: string, options: TranspileOptions): TranspileOutput;\n}\n/** @category Transpiler */\nexport interface TranspileOptions {\n fileName: string;\n}\n/** @category Transpiler */\nexport interface TranspileOutput {\n outputText: string;\n diagnostics?: ts.Diagnostic[];\n sourceMapText?: string;\n}\n"]}
|
||||
Reference in new issue
Block a user