Skip to content

Commit

Permalink
[internal] Keep the .cjs extension when compiling source files (#12820
Browse files Browse the repository at this point in the history
)

* [internal] Keep the .cjs extension when compiling

* yarn
  • Loading branch information
nicolo-ribaudo committed Feb 25, 2021
1 parent 74db827 commit b17231e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Gulpfile.mjs
Expand Up @@ -11,6 +11,7 @@ import babel from "gulp-babel";
import camelCase from "lodash/camelCase.js";
import fancyLog from "fancy-log";
import filter from "gulp-filter";
import revertPath from "gulp-revert-path";
import gulp from "gulp";
import { rollup } from "rollup";
import { babel as rollupBabel } from "@rollup/plugin-babel";
Expand Down Expand Up @@ -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(
// Passing 'file.relative' because newer() above uses a relative
// path and this keeps it consistent.
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -56,6 +56,7 @@
"gulp-filter": "^5.1.0",
"gulp-newer": "^1.0.0",
"gulp-plumber": "^1.2.1",
"gulp-revert-path": "^2.0.0",
"husky": "^3.0.0",
"jest": "^26.6.1",
"lint-staged": "^9.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/src/config/pattern-to-regex.js
Expand Up @@ -2,7 +2,7 @@
import path from "path";

// $FlowIgnore
import escapeRegExp from "./helpers/escape-regexp";
import escapeRegExp from "./helpers/escape-regexp.cjs";

const sep = `\\${path.sep}`;
const endSep = `(?:${sep}|$)`;
Expand Down
Expand Up @@ -15,7 +15,7 @@ import path from "path";
import vm from "vm";
import checkDuplicatedNodes from "babel-check-duplicated-nodes";
import QuickLRU from "quick-lru";
import escapeRegExp from "./escape-regexp";
import escapeRegExp from "./escape-regexp.cjs";

const cachedScripts = new QuickLRU({ maxSize: 10 });
const contextModuleCache = new WeakMap();
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-register/src/node.js
Expand Up @@ -7,7 +7,7 @@ import { addHook } from "pirates";
import fs from "fs";
import path from "path";
import Module from "module";
import escapeRegExp from "./escape-regexp";
import escapeRegExp from "./escape-regexp.cjs";

const maps = {};
let transformOpts = {};
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Expand Up @@ -5466,6 +5466,7 @@ __metadata:
gulp-filter: ^5.1.0
gulp-newer: ^1.0.0
gulp-plumber: ^1.2.1
gulp-revert-path: ^2.0.0
husky: ^3.0.0
jest: ^26.6.1
lint-staged: ^9.2.0
Expand Down Expand Up @@ -8735,6 +8736,15 @@ fsevents@^1.2.7:
languageName: node
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":
version: 4.0.2
resolution: "gulp@npm:4.0.2"
Expand Down

0 comments on commit b17231e

Please sign in to comment.