@react-pug/babel-plugin-react-pug 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -0
- package/package.json +22 -0
- package/tsconfig.json +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @react-pug/babel-plugin-react-pug
|
|
2
|
+
|
|
3
|
+
Babel plugin for transforming `pug\`...\`` tagged template literals in React code.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -D @react-pug/babel-plugin-react-pug
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
module.exports = {
|
|
15
|
+
plugins: [
|
|
16
|
+
['@react-pug/babel-plugin-react-pug', {
|
|
17
|
+
tagFunction: 'pug',
|
|
18
|
+
sourceMaps: 'detailed',
|
|
19
|
+
requirePugImport: false,
|
|
20
|
+
classShorthandProperty: 'auto',
|
|
21
|
+
classShorthandMerge: 'auto',
|
|
22
|
+
startupjsCssxjs: 'auto',
|
|
23
|
+
componentPathFromUppercaseClassShorthand: true
|
|
24
|
+
}]
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Options
|
|
30
|
+
|
|
31
|
+
- `tagFunction`: tagged template function name, default `pug`
|
|
32
|
+
- `mode`: `runtime | languageService`, default `runtime`
|
|
33
|
+
- `sourceMaps`: `basic | detailed`, default `basic`
|
|
34
|
+
- `requirePugImport`: boolean, default `false`
|
|
35
|
+
- `classShorthandProperty`: `auto | className | class | styleName`
|
|
36
|
+
- `classShorthandMerge`: `auto | concatenate | classnames`
|
|
37
|
+
- `startupjsCssxjs`: `never | auto | force`
|
|
38
|
+
- `componentPathFromUppercaseClassShorthand`: boolean, default `true`
|
|
39
|
+
|
|
40
|
+
When a `pug` import is present and used only for tagged templates, the plugin removes that binding from transformed output. If it was the only specifier in the declaration, the import is rewritten to a side-effect import to preserve module evaluation.
|
|
41
|
+
|
|
42
|
+
## Exports
|
|
43
|
+
|
|
44
|
+
- default Babel plugin
|
|
45
|
+
- `transformReactPugSourceForBabel(...)`
|
|
46
|
+
- `mapBabelGeneratedDiagnosticToOriginal(...)`
|
|
47
|
+
|
|
48
|
+
Published output is in `dist/`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PluginObj } from '@babel/core';
|
|
2
|
+
import type { ParseResult } from '@babel/parser';
|
|
3
|
+
import type { File } from '@babel/types';
|
|
4
|
+
import { type ClassAttributeOption, type ClassMergeOption, type StartupjsCssxjsOption, type GeneratedDiagnosticLike, type OriginalDiagnosticLocation, type PugDocument, type PugRegion, type TransformSourceMap } from '@react-pug/react-pug-core';
|
|
5
|
+
export type BabelPugCompileMode = 'runtime' | 'languageService';
|
|
6
|
+
export type BabelPugSourceMapMode = 'basic' | 'detailed';
|
|
7
|
+
export interface BabelReactPugPluginOptions {
|
|
8
|
+
tagFunction?: string;
|
|
9
|
+
mode?: BabelPugCompileMode;
|
|
10
|
+
sourceMaps?: BabelPugSourceMapMode;
|
|
11
|
+
requirePugImport?: boolean;
|
|
12
|
+
classShorthandProperty?: ClassAttributeOption;
|
|
13
|
+
classShorthandMerge?: ClassMergeOption;
|
|
14
|
+
startupjsCssxjs?: StartupjsCssxjsOption;
|
|
15
|
+
componentPathFromUppercaseClassShorthand?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface BabelReactPugMetadata {
|
|
18
|
+
document: PugDocument;
|
|
19
|
+
regions: PugRegion[];
|
|
20
|
+
}
|
|
21
|
+
export interface BabelReactPugTransformResult {
|
|
22
|
+
code: string;
|
|
23
|
+
metadata: BabelReactPugMetadata;
|
|
24
|
+
sourceMap: TransformSourceMap;
|
|
25
|
+
}
|
|
26
|
+
export declare function transformReactPugSourceForBabel(sourceText: string, fileName: string, options?: BabelReactPugPluginOptions): BabelReactPugTransformResult;
|
|
27
|
+
export declare function mapBabelGeneratedDiagnosticToOriginal(metadata: BabelReactPugMetadata, diagnostic: GeneratedDiagnosticLike): OriginalDiagnosticLocation | null;
|
|
28
|
+
export default function babelPluginReactPug(api: {
|
|
29
|
+
types: any;
|
|
30
|
+
}, options?: BabelReactPugPluginOptions): PluginObj & {
|
|
31
|
+
parserOverride?: (sourceText: string, parserOpts: {
|
|
32
|
+
sourceFileName?: string;
|
|
33
|
+
sourceFilename?: string;
|
|
34
|
+
}, parseWithBabel: (code: string, parserOpts: object) => ParseResult<File>) => ParseResult<File>;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,IAAI,EAA4B,MAAM,cAAc,CAAC;AACnE,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAE1B,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAChE,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sBAAsB,CAAC,EAAE,oBAAoB,CAAC;IAC9C,mBAAmB,CAAC,EAAE,gBAAgB,CAAC;IACvC,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,wCAAwC,CAAC,EAAE,OAAO,CAAC;CACpD;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,qBAAqB,CAAC;IAChC,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,0BAA+B,GACvC,4BAA4B,CAmB9B;AAED,wBAAgB,qCAAqC,CACnD,QAAQ,EAAE,qBAAqB,EAC/B,UAAU,EAAE,uBAAuB,GAClC,0BAA0B,GAAG,IAAI,CAEnC;AAcD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,GAAG,EAAE;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,EACnB,OAAO,GAAE,0BAA+B,GACvC,SAAS,GAAG;IACb,cAAc,CAAC,EAAE,CACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,EAChE,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,WAAW,CAAC,IAAI,CAAC,KACpE,WAAW,CAAC,IAAI,CAAC,CAAC;CACxB,CA0IA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformReactPugSourceForBabel = transformReactPugSourceForBabel;
|
|
4
|
+
exports.mapBabelGeneratedDiagnosticToOriginal = mapBabelGeneratedDiagnosticToOriginal;
|
|
5
|
+
exports.default = babelPluginReactPug;
|
|
6
|
+
const parser_1 = require("@babel/parser");
|
|
7
|
+
const react_pug_core_1 = require("@react-pug/react-pug-core");
|
|
8
|
+
function transformReactPugSourceForBabel(sourceText, fileName, options = {}) {
|
|
9
|
+
const transformed = (0, react_pug_core_1.transformSourceFile)(sourceText, fileName, {
|
|
10
|
+
tagFunction: options.tagFunction ?? 'pug',
|
|
11
|
+
compileMode: options.mode ?? 'runtime',
|
|
12
|
+
requirePugImport: options.requirePugImport ?? false,
|
|
13
|
+
classAttribute: options.classShorthandProperty ?? 'auto',
|
|
14
|
+
classMerge: options.classShorthandMerge ?? 'auto',
|
|
15
|
+
startupjsCssxjs: options.startupjsCssxjs ?? 'auto',
|
|
16
|
+
componentPathFromUppercaseClassShorthand: options.componentPathFromUppercaseClassShorthand ?? true,
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
code: transformed.code,
|
|
20
|
+
metadata: {
|
|
21
|
+
document: transformed.document,
|
|
22
|
+
regions: transformed.regions,
|
|
23
|
+
},
|
|
24
|
+
sourceMap: (0, react_pug_core_1.createTransformSourceMap)(transformed, fileName),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function mapBabelGeneratedDiagnosticToOriginal(metadata, diagnostic) {
|
|
28
|
+
return (0, react_pug_core_1.mapGeneratedDiagnosticToOriginal)(metadata.document, diagnostic);
|
|
29
|
+
}
|
|
30
|
+
function buildTransformCacheKey(sourceText, fileName) {
|
|
31
|
+
return `${fileName}\0${sourceText}`;
|
|
32
|
+
}
|
|
33
|
+
function parseRuntimeExpression(code) {
|
|
34
|
+
return (0, parser_1.parseExpression)(code, {
|
|
35
|
+
sourceType: 'module',
|
|
36
|
+
plugins: ['typescript', 'jsx', 'decorators-legacy'],
|
|
37
|
+
errorRecovery: false,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function babelPluginReactPug(api, options = {}) {
|
|
41
|
+
const tagFunction = options.tagFunction ?? 'pug';
|
|
42
|
+
const mode = options.mode ?? 'runtime';
|
|
43
|
+
const sourceMapsMode = options.sourceMaps ?? 'basic';
|
|
44
|
+
const requirePugImport = options.requirePugImport ?? false;
|
|
45
|
+
const transformCache = new Map();
|
|
46
|
+
function hasMatchingTagImport(programPath) {
|
|
47
|
+
return programPath.get('body').some((statementPath) => {
|
|
48
|
+
if (!statementPath.isImportDeclaration())
|
|
49
|
+
return false;
|
|
50
|
+
return statementPath.get('specifiers').some((specifierPath) => {
|
|
51
|
+
if (specifierPath.isImportSpecifier()) {
|
|
52
|
+
return (specifierPath.node.local?.name === tagFunction
|
|
53
|
+
&& specifierPath.node.imported?.type === 'Identifier'
|
|
54
|
+
&& specifierPath.node.imported.name === 'pug');
|
|
55
|
+
}
|
|
56
|
+
if (specifierPath.isImportDefaultSpecifier()) {
|
|
57
|
+
return specifierPath.node.local?.name === tagFunction;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const plugin = {
|
|
64
|
+
name: 'react-pug',
|
|
65
|
+
visitor: {
|
|
66
|
+
Program(path, state) {
|
|
67
|
+
const sourceText = state?.file?.code;
|
|
68
|
+
if (!sourceText)
|
|
69
|
+
return;
|
|
70
|
+
const fileName = state?.filename
|
|
71
|
+
?? state?.file?.opts?.filename
|
|
72
|
+
?? 'file.tsx';
|
|
73
|
+
const transformed = sourceMapsMode === 'detailed'
|
|
74
|
+
? transformCache.get(buildTransformCacheKey(sourceText, fileName))
|
|
75
|
+
: transformReactPugSourceForBabel(sourceText, fileName, {
|
|
76
|
+
tagFunction,
|
|
77
|
+
mode,
|
|
78
|
+
requirePugImport,
|
|
79
|
+
});
|
|
80
|
+
if (!transformed)
|
|
81
|
+
return;
|
|
82
|
+
if (transformed.metadata.regions.length === 0)
|
|
83
|
+
return;
|
|
84
|
+
if (sourceMapsMode === 'basic') {
|
|
85
|
+
if (requirePugImport && !hasMatchingTagImport(path)) {
|
|
86
|
+
throw path.buildCodeFrameError(`Missing import for tag function "${tagFunction}"`);
|
|
87
|
+
}
|
|
88
|
+
const taggedTemplates = new Map();
|
|
89
|
+
path.traverse({
|
|
90
|
+
TaggedTemplateExpression(taggedPath) {
|
|
91
|
+
const node = taggedPath.node;
|
|
92
|
+
if (typeof node.start !== 'number' || typeof node.end !== 'number')
|
|
93
|
+
return;
|
|
94
|
+
taggedTemplates.set(`${node.start}:${node.end}`, taggedPath);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const sortedRegions = [...transformed.metadata.regions]
|
|
98
|
+
.sort((a, b) => b.originalStart - a.originalStart);
|
|
99
|
+
for (const region of sortedRegions) {
|
|
100
|
+
const taggedPath = taggedTemplates.get(`${region.originalStart}:${region.originalEnd}`);
|
|
101
|
+
if (!taggedPath?.node)
|
|
102
|
+
continue;
|
|
103
|
+
taggedPath.replaceWith(parseRuntimeExpression(region.tsxText));
|
|
104
|
+
}
|
|
105
|
+
path.traverse({
|
|
106
|
+
ImportDeclaration(importPath) {
|
|
107
|
+
const sourceValue = importPath.node?.source?.value;
|
|
108
|
+
if (!sourceValue)
|
|
109
|
+
return;
|
|
110
|
+
const matched = importPath.node.specifiers.filter((specifier) => {
|
|
111
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
112
|
+
return specifier.local?.name === tagFunction && specifier.imported?.type === 'Identifier' && specifier.imported.name === 'pug';
|
|
113
|
+
}
|
|
114
|
+
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
115
|
+
return specifier.local?.name === tagFunction;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
});
|
|
119
|
+
if (matched.length === 0)
|
|
120
|
+
return;
|
|
121
|
+
importPath.node.specifiers = importPath.node.specifiers.filter((specifier) => !matched.includes(specifier));
|
|
122
|
+
if (importPath.node.specifiers.length === 0) {
|
|
123
|
+
if (importPath.node.importKind === 'type') {
|
|
124
|
+
importPath.remove();
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
importPath.replaceWith(api.types.importDeclaration([], api.types.stringLiteral(sourceValue)));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
path.scope.crawl();
|
|
133
|
+
}
|
|
134
|
+
state.file.metadata.reactPug = transformed.metadata;
|
|
135
|
+
transformCache.delete(buildTransformCacheKey(sourceText, fileName));
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
if (sourceMapsMode === 'detailed') {
|
|
140
|
+
plugin.parserOverride = (sourceText, parserOpts, parseWithBabel) => {
|
|
141
|
+
const fileName = parserOpts.sourceFileName ?? parserOpts.sourceFilename ?? 'file.tsx';
|
|
142
|
+
const transformed = transformReactPugSourceForBabel(sourceText, fileName, {
|
|
143
|
+
tagFunction,
|
|
144
|
+
mode,
|
|
145
|
+
requirePugImport,
|
|
146
|
+
});
|
|
147
|
+
transformCache.set(buildTransformCacheKey(sourceText, fileName), transformed);
|
|
148
|
+
if (transformed.metadata.regions.length === 0) {
|
|
149
|
+
return parseWithBabel(sourceText, parserOpts);
|
|
150
|
+
}
|
|
151
|
+
const inlineSourceMap = Buffer.from(JSON.stringify(transformed.sourceMap), 'utf8').toString('base64');
|
|
152
|
+
const codeWithMap = `${transformed.code}\n//# sourceMappingURL=data:application/json;base64,${inlineSourceMap}`;
|
|
153
|
+
return parseWithBabel(codeWithMap, parserOpts);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return plugin;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AA2CA,0EAuBC;AAED,sFAKC;AAcD,sCAmJC;AAzOD,0CAAgD;AAGhD,8DAYmC;AA2BnC,SAAgB,+BA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W,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9C,OAAO,cAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAChD,CAAC;YAED,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACtG,MAAM,WAAW,GAAG,GAAG,WAAW,CAAC,IAAI,uDAAuD,eAAe,EAAE,CAAC;YAChH,OAAO,cAAc,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-pug/babel-plugin-react-pug",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "npm --prefix ../.. run build -w @react-pug/react-pug-core && rm -rf dist && tsc -p tsconfig.build.json",
|
|
11
|
+
"prepublishOnly": "npm run build"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@babel/parser": "^7.0.0",
|
|
15
|
+
"@babel/types": "^7.0.0",
|
|
16
|
+
"@react-pug/react-pug-core": "^0.1.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@babel/core": "^7.0.0"
|
|
20
|
+
},
|
|
21
|
+
"gitHead": "b4e9f09659dd4c70d0734759ea00710414fd8366"
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": true,
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@react-pug/react-pug-core": [
|
|
8
|
+
"../react-pug-core/src/index.ts"
|
|
9
|
+
]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"src/**/*.ts"
|
|
14
|
+
],
|
|
15
|
+
"exclude": [
|
|
16
|
+
"dist"
|
|
17
|
+
]
|
|
18
|
+
}
|