@jscutlery/swc-angular-preset
Version:
## 👀 What is this?
91 lines (85 loc) • 2.89 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@swc/core');
function _extends() {
_extends = Object.assign || function assign(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
}
return target;
};
return _extends.apply(this, arguments);
}
assertCompatibleSwcCoreVersion();
function swcAngularPreset(options = {}) {
return {
jsc: {
parser: {
syntax: 'typescript',
decorators: true,
dynamicImport: true
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
experimental: {
plugins: [
[
'@jscutlery/swc-plugin-angular',
{
templateRawSuffix: options.templateRawSuffix
}
]
]
}
},
env: {
include: [
'transform-async-to-generator'
]
}
};
}
function swcAngularJestTransformer() {
return [
'@swc/jest',
swcAngularPreset()
];
}
function swcAngularVitePreset() {
return swcAngularPreset({
templateRawSuffix: true
});
}
function swcAngularUnpluginOptions() {
return _extends({}, swcAngularVitePreset(), {
/* Since we are using SWC's env option, we need to disable the tsconfigFile option.
* Otherwise `unpluggin-swc` will try to use the target from the tsconfig's `compilerOptions`,
* and make SWC produce the following error: "`env` and `jsc.target` cannot be used together".
*
* We could have added this extra option to `swcAngularVitePreset`, but forwarding any extra option
* to SWC will make SWC's configuration parser fail.
*
* Cf. https://github.com/unplugin/unplugin-swc/issues/137 */ tsconfigFile: false
});
}
/**
* @deprecated Use {@link swcAngularVitePreset}, {@link swcAngularJestTransformer} or {@link swcAngularPreset} instead.
*/ var index = swcAngularPreset();
function assertCompatibleSwcCoreVersion() {
if (!core.version.startsWith('1.4.')) {
console.warn(`
@swc/core version ${core.version} is incompatible with @jscutlery/swc-angular-preset.
Please use @swc/core version 1.4.x.
> npm add -D @swc/core@~1.4.0
`);
process.exit(1);
}
}
exports["default"] = index;
exports.swcAngularJestTransformer = swcAngularJestTransformer;
exports.swcAngularPreset = swcAngularPreset;
exports.swcAngularUnpluginOptions = swcAngularUnpluginOptions;
exports.swcAngularVitePreset = swcAngularVitePreset;