[internal] Keep the .cjs extension when compiling source files (#12820)

* [internal] Keep the .cjs extension when compiling

* yarn
This commit is contained in:
Nicolò Ribaudo 2021-02-25 18:03:05 +01:00 committed by GitHub
parent 74db827c0a
commit b17231e1af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import babel from "gulp-babel";
import camelCase from "lodash/camelCase.js"; import camelCase from "lodash/camelCase.js";
import fancyLog from "fancy-log"; import fancyLog from "fancy-log";
import filter from "gulp-filter"; import filter from "gulp-filter";
import revertPath from "gulp-revert-path";
import gulp from "gulp"; import gulp from "gulp";
import { rollup } from "rollup"; import { rollup } from "rollup";
import { babel as rollupBabel } from "@rollup/plugin-babel"; import { babel as rollupBabel } from "@rollup/plugin-babel";
@ -229,6 +230,10 @@ function buildBabel(exclude) {
}, },
}) })
) )
.pipe(
// gulp-babel always converts the extension to .js, but we want to keep the original one
revertPath()
)
.pipe( .pipe(
// Passing 'file.relative' because newer() above uses a relative // Passing 'file.relative' because newer() above uses a relative
// path and this keeps it consistent. // path and this keeps it consistent.

View File

@ -56,6 +56,7 @@
"gulp-filter": "^5.1.0", "gulp-filter": "^5.1.0",
"gulp-newer": "^1.0.0", "gulp-newer": "^1.0.0",
"gulp-plumber": "^1.2.1", "gulp-plumber": "^1.2.1",
"gulp-revert-path": "^2.0.0",
"husky": "^3.0.0", "husky": "^3.0.0",
"jest": "^26.6.1", "jest": "^26.6.1",
"lint-staged": "^9.2.0", "lint-staged": "^9.2.0",

View File

@ -2,7 +2,7 @@
import path from "path"; import path from "path";
// $FlowIgnore // $FlowIgnore
import escapeRegExp from "./helpers/escape-regexp"; import escapeRegExp from "./helpers/escape-regexp.cjs";
const sep = `\\${path.sep}`; const sep = `\\${path.sep}`;
const endSep = `(?:${sep}|$)`; const endSep = `(?:${sep}|$)`;

View File

@ -15,7 +15,7 @@ import path from "path";
import vm from "vm"; import vm from "vm";
import checkDuplicatedNodes from "babel-check-duplicated-nodes"; import checkDuplicatedNodes from "babel-check-duplicated-nodes";
import QuickLRU from "quick-lru"; import QuickLRU from "quick-lru";
import escapeRegExp from "./escape-regexp"; import escapeRegExp from "./escape-regexp.cjs";
const cachedScripts = new QuickLRU({ maxSize: 10 }); const cachedScripts = new QuickLRU({ maxSize: 10 });
const contextModuleCache = new WeakMap(); const contextModuleCache = new WeakMap();

View File

@ -7,7 +7,7 @@ import { addHook } from "pirates";
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import Module from "module"; import Module from "module";
import escapeRegExp from "./escape-regexp"; import escapeRegExp from "./escape-regexp.cjs";
const maps = {}; const maps = {};
let transformOpts = {}; let transformOpts = {};

View File

@ -5466,6 +5466,7 @@ __metadata:
gulp-filter: ^5.1.0 gulp-filter: ^5.1.0
gulp-newer: ^1.0.0 gulp-newer: ^1.0.0
gulp-plumber: ^1.2.1 gulp-plumber: ^1.2.1
gulp-revert-path: ^2.0.0
husky: ^3.0.0 husky: ^3.0.0
jest: ^26.6.1 jest: ^26.6.1
lint-staged: ^9.2.0 lint-staged: ^9.2.0
@ -8735,6 +8736,15 @@ fsevents@^1.2.7:
languageName: node languageName: node
linkType: hard linkType: hard
"gulp-revert-path@npm:^2.0.0":
version: 2.0.0
resolution: "gulp-revert-path@npm:2.0.0"
dependencies:
through2: ^2.0.0
checksum: c2b01db2942c084f8cb11cecff22663a3ab894cdf43daed601bdaa9c713797e11739415b46f18342171fb0c65c1fe57d18dd40f93da403002e99f453b5661d77
languageName: node
linkType: hard
"gulp@npm:^4.0.2": "gulp@npm:^4.0.2":
version: 4.0.2 version: 4.0.2
resolution: "gulp@npm:4.0.2" resolution: "gulp@npm:4.0.2"