Update plugin build system (#14571)
This commit is contained in:
1 parent
413a76d798
commit
6d21de11fd
60 files changed
+356
-389
No files matched your search
@@ -170,20 +170,13 @@ function getEsbuildOptions({ file, files, shouldCollectLicenses, cliOptions }) {
|
||||
{
|
||||
module: "module",
|
||||
text: "export const createRequire = () => {};",
|
||||
},
|
||||
// This module requires file access, should not include in universal bundle
|
||||
{
|
||||
module: path.join(PROJECT_ROOT, "src/utils/get-interpreter.js"),
|
||||
text: "export default undefined;",
|
||||
}
|
||||
);
|
||||
|
||||
// Replace parser getters with `undefined`
|
||||
for (const file of [
|
||||
"src/language-js/parse/parsers.js",
|
||||
// This module requires file access, should not include in universal bundle
|
||||
"src/utils/get-interpreter.js",
|
||||
]) {
|
||||
replaceModule.push({
|
||||
module: path.join(PROJECT_ROOT, file),
|
||||
text: "export default undefined;",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const { buildOptions } = file;
|
||||
|
||||
@@ -52,7 +52,7 @@ async function buildPackageJson({ file, files }) {
|
||||
)
|
||||
.flatMap((file) => {
|
||||
let basename = path.basename(file.output.file, ".js");
|
||||
if (basename === "acorn-and-espree") {
|
||||
if (basename === "acorn") {
|
||||
basename = "espree";
|
||||
}
|
||||
return [
|
||||
|
||||
+14
-19
@@ -88,7 +88,7 @@ const extensions = {
|
||||
const pluginFiles = [
|
||||
"src/plugins/estree.js",
|
||||
{
|
||||
input: "src/language-js/parse/babel.js",
|
||||
input: "src/plugins/babel.js",
|
||||
replaceModule: [
|
||||
{
|
||||
// We don't use value of JSXText
|
||||
@@ -102,7 +102,7 @@ const pluginFiles = [
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/language-js/parse/flow.js",
|
||||
input: "src/plugins/flow.js",
|
||||
replaceModule: [
|
||||
{
|
||||
module: require.resolve("flow-parser"),
|
||||
@@ -114,7 +114,7 @@ const pluginFiles = [
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/language-js/parse/typescript.js",
|
||||
input: "src/plugins/typescript.js",
|
||||
replaceModule: [
|
||||
{
|
||||
module: require.resolve("typescript"),
|
||||
@@ -208,8 +208,7 @@ const pluginFiles = [
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/language-js/parse/acorn-and-espree.js",
|
||||
umdPropertyName: "acornAndEspree",
|
||||
input: "src/plugins/acorn.js",
|
||||
replaceModule: [
|
||||
{
|
||||
module: require.resolve("espree"),
|
||||
@@ -233,7 +232,7 @@ const pluginFiles = [
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/language-js/parse/meriyah.js",
|
||||
input: "src/plugins/meriyah.js",
|
||||
replaceModule: [
|
||||
{
|
||||
// We don't use value of JSXText
|
||||
@@ -244,7 +243,7 @@ const pluginFiles = [
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/language-js/parse/angular.js",
|
||||
input: "src/plugins/angular.js",
|
||||
replaceModule: [
|
||||
// We only use a small set of `@angular/compiler` from `esm2020/src/expression_parser/`
|
||||
// Those files can't be imported, they also not directly runnable, because `.mjs` extension is missing
|
||||
@@ -268,8 +267,7 @@ const pluginFiles = [
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/language-css/index.js",
|
||||
outputBaseName: "postcss",
|
||||
input: "src/plugins/postcss.js",
|
||||
replaceModule: [
|
||||
// The following two replacements prevent load `source-map` module
|
||||
{
|
||||
@@ -309,9 +307,9 @@ const pluginFiles = [
|
||||
},
|
||||
],
|
||||
},
|
||||
"src/language-graphql/index.js",
|
||||
"src/plugins/graphql.js",
|
||||
{
|
||||
input: "src/language-markdown/index.js",
|
||||
input: "src/plugins/markdown.js",
|
||||
replaceModule: [
|
||||
{
|
||||
module: getPackageFile("parse-entities/decode-entity.browser.js"),
|
||||
@@ -320,8 +318,7 @@ const pluginFiles = [
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/language-handlebars/index.js",
|
||||
outputBaseName: "glimmer",
|
||||
input: "src/plugins/glimmer.js",
|
||||
replaceModule: [
|
||||
// See comment in `src/language-handlebars/parser-glimmer.js` file
|
||||
{
|
||||
@@ -346,8 +343,8 @@ const pluginFiles = [
|
||||
},
|
||||
],
|
||||
},
|
||||
"src/language-html/index.js",
|
||||
"src/language-yaml/index.js",
|
||||
"src/plugins/html.js",
|
||||
"src/plugins/yaml.js",
|
||||
].map((file) => {
|
||||
if (typeof file === "string") {
|
||||
file = { input: file };
|
||||
@@ -355,10 +352,8 @@ const pluginFiles = [
|
||||
|
||||
let { input, umdPropertyName, outputBaseName, ...buildOptions } = file;
|
||||
|
||||
outputBaseName ??= (
|
||||
input.match(/\/(?:parser-|parse\/|plugins\/)(?<outputBaseName>.*?)\.js$/) ??
|
||||
input.match(/\/language-(?<outputBaseName>.*?)\/index\.js$/)
|
||||
).groups.outputBaseName;
|
||||
outputBaseName ??= input.match(/\/plugins\/(?<outputBaseName>.*?)\.js$/)
|
||||
.groups.outputBaseName;
|
||||
|
||||
const umdVariableName = `prettierPlugins.${
|
||||
umdPropertyName ?? outputBaseName
|
||||
|
||||
Reference in new issue
Block a user