@dawnjs/dn-middleware-babel
Advanced tools
Comparing version 2.0.8 to 2.1.0
@@ -68,6 +68,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -97,7 +101,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
env = opts.env, cwd = opts.cwd, watch = opts.watch, _a = opts.type, type = _a === void 0 ? "cjs" : _a, _b = opts.srcDir, srcDir = _b === void 0 ? "src" : _b, output = opts.output, _c = opts.target, target = _c === void 0 ? "node" : _c, _d = opts.include, include = _d === void 0 ? ["**/*"] : _d, _e = opts.exclude, exclude = _e === void 0 ? ["**/__test__{,/**}", "**/*.+(test|e2e|spec).+(js|jsx|ts|tsx)"] : _e, runtimeHelpers = opts.runtimeHelpers, corejs = opts.corejs, jsxRuntime = opts.jsxRuntime, pragma = opts.pragma, pragmaFrag = opts.pragmaFrag, disableAutoReactRequire = opts.disableAutoReactRequire, _f = opts.extraPresets, extraPresets = _f === void 0 ? [] : _f, _g = opts.extraPlugins, extraPlugins = _g === void 0 ? [] : _g, nodeVersion = opts.nodeVersion, disableTypeCheck = opts.disableTypeCheck, noEmit = opts.noEmit; | ||
srcPath = path_1.resolve(cwd, srcDir); | ||
srcPath = (0, path_1.resolve)(cwd, srcDir); | ||
outputDir = output || (type === "cjs" ? "lib" : "es"); | ||
outputPath = path_1.resolve(cwd, outputDir); | ||
patterns = include.map(function (p) { return path_1.join(srcPath, p); }).concat(exclude.map(function (p) { return "!" + path_1.join(srcPath, p); })); | ||
babelOpts = getBabelConfig_1.getBabelConfig({ | ||
outputPath = (0, path_1.resolve)(cwd, outputDir); | ||
patterns = include.map(function (p) { return (0, path_1.join)(srcPath, p); }).concat(exclude.map(function (p) { return "!" + (0, path_1.join)(srcPath, p); })); | ||
babelOpts = (0, getBabelConfig_1.getBabelConfig)({ | ||
env: env, | ||
@@ -129,12 +133,12 @@ target: target, | ||
transform = function (file) { | ||
ctx.console.log("Transform to " + type + " for " + path_1.relative(cwd, file.path)); | ||
return babel.transform(file.contents, __assign(__assign({}, babelOpts), { filename: file.path })).code; | ||
ctx.console.log("Transform to " + type + " for " + (0, path_1.relative)(cwd, file.path)); | ||
return babel.transformSync(file.contents, __assign(__assign({}, babelOpts), { filename: file.path })).code; | ||
}; | ||
getTSConfig = function () { | ||
var tsConfigPath = path_1.join(cwd, "tsconfig.json"); | ||
var templateTSConfigPath = path_1.join(__dirname, "../template/tsconfig.json"); | ||
if (fs_1.existsSync(tsConfigPath)) { | ||
return utils_1.getTSConfigCompilerOptions(tsConfigPath) || {}; | ||
var tsConfigPath = (0, path_1.join)(cwd, "tsconfig.json"); | ||
var templateTSConfigPath = (0, path_1.join)(__dirname, "../template/tsconfig.json"); | ||
if ((0, fs_1.existsSync)(tsConfigPath)) { | ||
return (0, utils_1.getTSConfigCompilerOptions)(tsConfigPath) || {}; | ||
} | ||
return utils_1.getTSConfigCompilerOptions(templateTSConfigPath) || {}; | ||
return (0, utils_1.getTSConfigCompilerOptions)(templateTSConfigPath) || {}; | ||
}; | ||
@@ -147,7 +151,7 @@ createStream = function (src) { | ||
.src(src, { allowEmpty: true, base: srcPath }) | ||
.pipe(gulp_if_1.default(function (f) { return !disableTypeCheck && utils_1.isTransform(f.path, tsFileRegexp); }, gulp_typescript_1.default(tsConfig))) // Transform ts file with tsc if need type check | ||
.pipe(gulp_if_1.default(function (f) { return utils_1.isTransform(f.path, babelTransformRegexp); }, through2_1.default.obj(function (file, enc, cb) { | ||
.pipe((0, gulp_if_1.default)(function (f) { return !disableTypeCheck && (0, utils_1.isTransform)(f.path, tsFileRegexp); }, (0, gulp_typescript_1.default)(tsConfig))) // Transform ts file with tsc if need type check | ||
.pipe((0, gulp_if_1.default)(function (f) { return (0, utils_1.isTransform)(f.path, babelTransformRegexp); }, through2_1.default.obj(function (file, enc, cb) { | ||
try { | ||
file.contents = Buffer.from(transform(file)); // eslint-disable-line no-param-reassign | ||
file.path = file.path.replace(path_1.extname(file.path), ".js"); // eslint-disable-line no-param-reassign | ||
file.path = file.path.replace((0, path_1.extname)(file.path), ".js"); // eslint-disable-line no-param-reassign | ||
cb(null, file); | ||
@@ -167,16 +171,16 @@ } | ||
if (watch) { | ||
ctx.console.info("Start watching " + path_1.relative(cwd, srcPath) + " directory..."); | ||
ctx.console.info("Start watching " + (0, path_1.relative)(cwd, srcPath) + " directory..."); | ||
var watcher_1 = chokidar.watch(patterns, { ignoreInitial: true }); | ||
var files_1 = []; | ||
// Debounce file change event | ||
var compileFiles_1 = lodash_1.debounce(function () { | ||
createStream(__spreadArray([], files_1)); | ||
var compileFiles_1 = (0, lodash_1.debounce)(function () { | ||
createStream(__spreadArray([], files_1, true)); | ||
files_1.length = 0; | ||
}, 1000); | ||
watcher_1.on("all", function (event, fullPath) { | ||
ctx.console.info("[" + event + "] " + path_1.relative(cwd, fullPath)); | ||
if (!fs_1.existsSync(fullPath)) { | ||
ctx.console.info("[" + event + "] " + (0, path_1.relative)(cwd, fullPath)); | ||
if (!(0, fs_1.existsSync)(fullPath)) { | ||
return; | ||
} | ||
if (fs_1.statSync(fullPath).isFile()) { | ||
if ((0, fs_1.statSync)(fullPath).isFile()) { | ||
if (!files_1.includes(fullPath)) { | ||
@@ -183,0 +187,0 @@ files_1.push(fullPath); |
@@ -30,3 +30,3 @@ "use strict"; | ||
development: env === "development", | ||
runtime: utils_1.hasJsxRuntime() ? jsxRuntime || "classic" : "classic", | ||
runtime: (0, utils_1.hasJsxRuntime)() ? jsxRuntime || "classic" : "classic", | ||
pragma: pragma, | ||
@@ -36,3 +36,3 @@ pragmaFrag: pragmaFrag, | ||
: false, | ||
reactRequire: !(disableAutoReactRequire === true || (jsxRuntime === "automatic" && utils_1.hasJsxRuntime())), | ||
reactRequire: !(disableAutoReactRequire === true || (jsxRuntime === "automatic" && (0, utils_1.hasJsxRuntime)())), | ||
transformRuntime: runtimeHelpers | ||
@@ -39,0 +39,0 @@ ? __assign({ useESModules: isBrowser && type === "esm", corejs: corejs }, (typeof runtimeHelpers === "string" ? { version: runtimeHelpers } : {})) : undefined, |
@@ -47,3 +47,3 @@ "use strict";; | ||
case 0: | ||
opts = opts_1.getOpts(options, ctx); | ||
opts = (0, opts_1.getOpts)(options, ctx); | ||
if (!ctx.emit) return [3 /*break*/, 2]; | ||
@@ -55,6 +55,6 @@ ctx.emit("babel.opts", opts); | ||
_a.label = 2; | ||
case 2: return [4 /*yield*/, opts_1.validateOpts(opts, ctx)]; | ||
case 2: return [4 /*yield*/, (0, opts_1.validateOpts)(opts, ctx)]; | ||
case 3: | ||
_a.sent(); | ||
return [4 /*yield*/, babel_1.run(opts, ctx)]; | ||
return [4 /*yield*/, (0, babel_1.run)(opts, ctx)]; | ||
case 4: | ||
@@ -61,0 +61,0 @@ babelOpts = _a.sent(); |
@@ -44,3 +44,3 @@ "use strict"; | ||
var getOpts = function (opts, ctx) { | ||
return lodash_1.merge({ cwd: ctx.cwd, env: process.env.NODE_ENV }, opts); | ||
return (0, lodash_1.merge)({ cwd: ctx.cwd, env: process.env.NODE_ENV }, opts); | ||
}; | ||
@@ -84,7 +84,7 @@ exports.getOpts = getOpts; | ||
if (!(target === "browser")) return [3 /*break*/, 11]; | ||
if (!!fs_1.existsSync(path_1.join(cwd, ".browserslistrc"))) return [3 /*break*/, 11]; | ||
if (!!(0, fs_1.existsSync)((0, path_1.join)(cwd, ".browserslistrc"))) return [3 /*break*/, 11]; | ||
ctx.console.warn("No .browserslistrc found for browser target. Using default..."); | ||
_b = (_a = ctx.utils).writeFile; | ||
_c = [path_1.join(cwd, ".browserslistrc")]; | ||
return [4 /*yield*/, ctx.utils.readFile(path_1.join(__dirname, "../template/browserslistrc"))]; | ||
_c = [(0, path_1.join)(cwd, ".browserslistrc")]; | ||
return [4 /*yield*/, ctx.utils.readFile((0, path_1.join)(__dirname, "../template/browserslistrc"))]; | ||
case 9: return [4 /*yield*/, _b.apply(_a, _c.concat([_g.sent()]))]; | ||
@@ -91,0 +91,0 @@ case 10: |
@@ -26,3 +26,3 @@ "use strict"; | ||
var parseTSConfig = function (path) { | ||
var result = ts.readConfigFile(path, function (file) { return fs_1.readFileSync(file, "utf-8"); }); | ||
var result = ts.readConfigFile(path, function (file) { return (0, fs_1.readFileSync)(file, "utf-8"); }); | ||
if (result.error) { | ||
@@ -35,3 +35,3 @@ return; | ||
var getTSConfigCompilerOptions = function (path) { | ||
var config = exports.parseTSConfig(path); | ||
var config = (0, exports.parseTSConfig)(path); | ||
return config ? config.compilerOptions : undefined; | ||
@@ -38,0 +38,0 @@ }; |
{ | ||
"name": "@dawnjs/dn-middleware-babel", | ||
"version": "2.0.8", | ||
"version": "2.1.0", | ||
"description": "Transform code with babel", | ||
@@ -35,12 +35,12 @@ "keywords": [ | ||
"@dawnjs/types": "^2.0.1", | ||
"@types/babel__core": "^7.1.12", | ||
"@types/gulp-if": "0.0.33", | ||
"@types/lodash": "^4.14.165", | ||
"@types/babel__core": "^7.1.16", | ||
"@types/gulp-if": "0.0.34", | ||
"@types/lodash": "^4.14.177", | ||
"@types/through2": "^2.0.36", | ||
"@types/vinyl-fs": "^2.4.11" | ||
"@types/vinyl-fs": "^2.4.12" | ||
}, | ||
"dependencies": { | ||
"@babel/core": "^7.12.3", | ||
"@dawnjs/babel-preset-dawn": "^2.2.0", | ||
"chokidar": "^3.5.1", | ||
"@babel/core": "^7.16.0", | ||
"@dawnjs/babel-preset-dawn": "^2.2.1", | ||
"chokidar": "^3.5.2", | ||
"gulp-if": "^3.0.0", | ||
@@ -50,7 +50,7 @@ "gulp-typescript": "^5.0.1", | ||
"through2": "^4.0.2", | ||
"typescript": "^4.2.4", | ||
"typescript": "^4.4.4", | ||
"vinyl-fs": "^3.0.3" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "ec9a20e0a20cd47fe9b97802f93660bb910065e7" | ||
"gitHead": "bac5fba9b5eb4679b1bb954c30d793c698966915" | ||
} |
38310
553
Updated@babel/core@^7.16.0
Updatedchokidar@^3.5.2
Updatedtypescript@^4.4.4