@teleporthq/teleport-postprocessor-prettier-js
Advanced tools
Comparing version
@@ -1,68 +0,39 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var standalone_js_1 = __importDefault(require("prettier/standalone.js")); | ||
var format = standalone_js_1.default.format; | ||
var parser_babel_js_1 = __importDefault(require("prettier/parser-babel.js")); | ||
var teleport_shared_1 = require("@teleporthq/teleport-shared"); | ||
var teleport_types_1 = require("@teleporthq/teleport-types"); | ||
exports.createPrettierJSPostProcessor = function (options) { | ||
if (options === void 0) { options = {}; } | ||
var fileType = options.fileType || teleport_types_1.FileType.JS; | ||
var formatOptions = __assign(__assign({}, teleport_shared_1.Constants.PRETTIER_CONFIG), options.formatOptions); | ||
var plugins = [parser_babel_js_1.default]; | ||
var processor = function (codeChunks) { | ||
if (codeChunks[fileType]) { | ||
codeChunks[fileType] = format(codeChunks[fileType], __assign(__assign({}, formatOptions), { plugins: plugins, parser: 'babel' })); | ||
} | ||
else { | ||
console.warn('No code chunk of type JS found, prettier-js did not perform any operation'); | ||
} | ||
return codeChunks; | ||
}; | ||
return processor; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); | ||
}; | ||
// packages/teleport-postprocessor-prettier-js/src/index.ts | ||
__markAsModule(exports); | ||
__export(exports, { | ||
createPrettierJSPostProcessor: () => createPrettierJSPostProcessor, | ||
default: () => src_default | ||
}); | ||
var import_standalone = __toModule(require("prettier/standalone")); | ||
var import_parser_babel = __toModule(require("prettier/parser-babel")); | ||
var import_teleport_shared = __toModule(require("@teleporthq/teleport-shared")); | ||
var import_teleport_types = __toModule(require("@teleporthq/teleport-types")); | ||
var createPrettierJSPostProcessor = (options = {}) => { | ||
const fileType = options.fileType || import_teleport_types.FileType.JS; | ||
const formatOptions = __spreadValues(__spreadValues({}, import_teleport_shared.Constants.PRETTIER_CONFIG), options.formatOptions); | ||
const plugins = [import_parser_babel.default]; | ||
const processor = (codeChunks) => { | ||
if (codeChunks[fileType]) { | ||
codeChunks[fileType] = (0, import_standalone.format)(codeChunks[fileType], __spreadProps(__spreadValues({}, formatOptions), { | ||
plugins, | ||
parser: "babel" | ||
})); | ||
} else { | ||
console.warn("No code chunk of type JS found, prettier-js did not perform any operation"); | ||
} | ||
return codeChunks; | ||
}; | ||
return processor; | ||
}; | ||
var src_default = createPrettierJSPostProcessor(); | ||
exports.default = exports.createPrettierJSPostProcessor(); | ||
//# sourceMappingURL=index.js.map |
@@ -1,47 +0,34 @@ | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
// packages/teleport-postprocessor-prettier-js/src/index.ts | ||
import { format } from "prettier/standalone"; | ||
import parserBabel from "prettier/parser-babel"; | ||
import { Constants } from "@teleporthq/teleport-shared"; | ||
import { FileType } from "@teleporthq/teleport-types"; | ||
var createPrettierJSPostProcessor = (options = {}) => { | ||
const fileType = options.fileType || FileType.JS; | ||
const formatOptions = __spreadValues(__spreadValues({}, Constants.PRETTIER_CONFIG), options.formatOptions); | ||
const plugins = [parserBabel]; | ||
const processor = (codeChunks) => { | ||
if (codeChunks[fileType]) { | ||
codeChunks[fileType] = format(codeChunks[fileType], __spreadProps(__spreadValues({}, formatOptions), { | ||
plugins, | ||
parser: "babel" | ||
})); | ||
} else { | ||
console.warn("No code chunk of type JS found, prettier-js did not perform any operation"); | ||
} | ||
return codeChunks; | ||
}; | ||
return processor; | ||
import standalone from 'prettier/standalone.js'; | ||
var format = standalone.format; | ||
import parserBabel from 'prettier/parser-babel.js'; | ||
import { Constants } from '@teleporthq/teleport-shared'; | ||
import { FileType } from '@teleporthq/teleport-types'; | ||
export var createPrettierJSPostProcessor = function (options) { | ||
if (options === void 0) { options = {}; } | ||
var fileType = options.fileType || FileType.JS; | ||
var formatOptions = __assign(__assign({}, Constants.PRETTIER_CONFIG), options.formatOptions); | ||
var plugins = [parserBabel]; | ||
var processor = function (codeChunks) { | ||
if (codeChunks[fileType]) { | ||
codeChunks[fileType] = format(codeChunks[fileType], __assign(__assign({}, formatOptions), { plugins: plugins, parser: 'babel' })); | ||
} | ||
else { | ||
console.warn('No code chunk of type JS found, prettier-js did not perform any operation'); | ||
} | ||
return codeChunks; | ||
}; | ||
return processor; | ||
}; | ||
var src_default = createPrettierJSPostProcessor(); | ||
export { | ||
createPrettierJSPostProcessor, | ||
src_default as default | ||
}; | ||
export default createPrettierJSPostProcessor(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@teleporthq/teleport-postprocessor-prettier-js", | ||
"version": "0.17.0", | ||
"version": "0.17.3", | ||
"description": "A post-processing function that formats js code chunks using prettier and the babylon parser", | ||
@@ -9,9 +9,4 @@ "author": "teleportHQ", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/cjs/index.d.ts", | ||
"module": "dist/esm/index.js", | ||
"exports": { | ||
"module": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"import": "./dist/esm/index.js" | ||
}, | ||
"sideEffects": false, | ||
@@ -30,10 +25,10 @@ "repository": { | ||
"clean": "rimraf dist", | ||
"types": "tsc -p tsconfig.json" | ||
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs" | ||
}, | ||
"dependencies": { | ||
"@teleporthq/teleport-shared": "^0.17.0", | ||
"@teleporthq/teleport-types": "^0.17.0", | ||
"prettier": "^2.2.1" | ||
"@teleporthq/teleport-shared": "^0.17.3", | ||
"@teleporthq/teleport-types": "^0.17.3", | ||
"prettier": "^2.3.1" | ||
}, | ||
"gitHead": "959317a18068b52ffd8b912e41d123f70d97e7bc" | ||
"gitHead": "1a673d148f2626c5488092f3e88b3a9d7c9725b4" | ||
} |
@@ -1,5 +0,4 @@ | ||
import { format } from 'prettier/standalone' | ||
import parserBabel from 'prettier/parser-babel' | ||
import standalone from 'prettier/standalone.js' | ||
const { format } = standalone | ||
import parserBabel from 'prettier/parser-babel.js' | ||
import { Constants } from '@teleporthq/teleport-shared' | ||
@@ -6,0 +5,0 @@ import { PostProcessor, PrettierFormatOptions, FileType } from '@teleporthq/teleport-types' |
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"emitDeclarationOnly": true, | ||
"outDir": "dist/cjs" | ||
"outDir": "dist/esm" | ||
}, | ||
@@ -7,0 +6,0 @@ "include": [ |
Sorry, the diff of this file is not supported yet
130592
79.21%14
40%146
-18.89%Updated