@parcel/transformer-pug 2.0.0-nightly.97 → 2.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/lib/PugTransformer.js +51 -26
- package/package.json +10 -8
- package/src/PugTransformer.js +19 -18
package/lib/PugTransformer.js
CHANGED
|
@@ -5,51 +5,76 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function _path() {
|
|
9
|
+
const data = _interopRequireDefault(require("path"));
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
_path = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _plugin() {
|
|
19
|
+
const data = require("@parcel/plugin");
|
|
20
|
+
|
|
21
|
+
_plugin = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _pug() {
|
|
29
|
+
const data = _interopRequireDefault(require("pug"));
|
|
30
|
+
|
|
31
|
+
_pug = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
11
37
|
|
|
12
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
39
|
|
|
14
|
-
var _default = new _plugin.Transformer({
|
|
15
|
-
async
|
|
16
|
-
|
|
40
|
+
var _default = new (_plugin().Transformer)({
|
|
41
|
+
async loadConfig({
|
|
42
|
+
config
|
|
17
43
|
}) {
|
|
18
|
-
|
|
19
|
-
|
|
44
|
+
let configFile = await config.getConfig(['.pugrc', '.pugrc.js', 'pug.config.js']);
|
|
45
|
+
|
|
46
|
+
if (configFile) {
|
|
47
|
+
let isJavascript = _path().default.extname(configFile.filePath) === '.js';
|
|
48
|
+
|
|
49
|
+
if (isJavascript) {
|
|
50
|
+
config.invalidateOnStartup();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return configFile.contents;
|
|
54
|
+
}
|
|
20
55
|
},
|
|
21
56
|
|
|
22
57
|
async transform({
|
|
23
58
|
asset,
|
|
24
|
-
config
|
|
25
|
-
options
|
|
59
|
+
config
|
|
26
60
|
}) {
|
|
27
|
-
|
|
28
|
-
return [asset];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const pug = await options.packageManager.require('pug', asset.filePath);
|
|
61
|
+
const pugConfig = config !== null && config !== void 0 ? config : {};
|
|
32
62
|
const content = await asset.getCode();
|
|
33
|
-
|
|
34
|
-
|
|
63
|
+
|
|
64
|
+
const render = _pug().default.compile(content, {
|
|
35
65
|
compileDebug: false,
|
|
36
|
-
basedir: _path.default.dirname(asset.filePath),
|
|
66
|
+
basedir: _path().default.dirname(asset.filePath),
|
|
37
67
|
filename: asset.filePath,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
filters: config.filters,
|
|
41
|
-
filterOptions: config.filterOptions,
|
|
42
|
-
filterAliases: config.filterAliases
|
|
68
|
+
...pugConfig,
|
|
69
|
+
pretty: pugConfig.pretty || false
|
|
43
70
|
});
|
|
44
71
|
|
|
45
72
|
for (let filePath of render.dependencies) {
|
|
46
|
-
await asset.
|
|
47
|
-
filePath
|
|
48
|
-
});
|
|
73
|
+
await asset.invalidateOnFileChange(filePath);
|
|
49
74
|
}
|
|
50
75
|
|
|
51
76
|
asset.type = 'html';
|
|
52
|
-
asset.setCode(render(
|
|
77
|
+
asset.setCode(render(pugConfig.locals));
|
|
53
78
|
return [asset];
|
|
54
79
|
}
|
|
55
80
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-pug",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
+
"funding": {
|
|
9
|
+
"type": "opencollective",
|
|
10
|
+
"url": "https://opencollective.com/parcel"
|
|
11
|
+
},
|
|
8
12
|
"repository": {
|
|
9
13
|
"type": "git",
|
|
10
14
|
"url": "https://github.com/parcel-bundler/parcel.git"
|
|
@@ -12,14 +16,12 @@
|
|
|
12
16
|
"main": "lib/PugTransformer.js",
|
|
13
17
|
"source": "src/PugTransformer.js",
|
|
14
18
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
16
|
-
"parcel": "^2.
|
|
19
|
+
"node": ">= 12.0.0",
|
|
20
|
+
"parcel": "^2.1.0"
|
|
17
21
|
},
|
|
18
22
|
"dependencies": {
|
|
19
|
-
"@parcel/plugin": "2.
|
|
20
|
-
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"pug": "^2.0.4"
|
|
23
|
+
"@parcel/plugin": "^2.1.0",
|
|
24
|
+
"pug": "^3.0.2"
|
|
23
25
|
},
|
|
24
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "5a80fbe4af8797d0aab248a66f5254f42f00e83e"
|
|
25
27
|
}
|
package/src/PugTransformer.js
CHANGED
|
@@ -2,43 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import {Transformer} from '@parcel/plugin';
|
|
5
|
+
import pug from 'pug';
|
|
5
6
|
|
|
6
|
-
export default new Transformer({
|
|
7
|
-
async
|
|
8
|
-
|
|
7
|
+
export default (new Transformer({
|
|
8
|
+
async loadConfig({config}) {
|
|
9
|
+
let configFile = await config.getConfig([
|
|
9
10
|
'.pugrc',
|
|
10
11
|
'.pugrc.js',
|
|
11
12
|
'pug.config.js',
|
|
12
13
|
]);
|
|
13
|
-
return config || {};
|
|
14
|
-
},
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (configFile) {
|
|
16
|
+
let isJavascript = path.extname(configFile.filePath) === '.js';
|
|
17
|
+
if (isJavascript) {
|
|
18
|
+
config.invalidateOnStartup();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return configFile.contents;
|
|
19
22
|
}
|
|
23
|
+
},
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
async transform({asset, config}) {
|
|
26
|
+
const pugConfig = config ?? {};
|
|
22
27
|
const content = await asset.getCode();
|
|
23
28
|
const render = pug.compile(content, {
|
|
24
|
-
degug: true,
|
|
25
29
|
compileDebug: false,
|
|
26
30
|
basedir: path.dirname(asset.filePath),
|
|
27
31
|
filename: asset.filePath,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
filters: config.filters,
|
|
31
|
-
filterOptions: config.filterOptions,
|
|
32
|
-
filterAliases: config.filterAliases,
|
|
32
|
+
...pugConfig,
|
|
33
|
+
pretty: pugConfig.pretty || false,
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
for (let filePath of render.dependencies) {
|
|
36
|
-
await asset.
|
|
37
|
+
await asset.invalidateOnFileChange(filePath);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
asset.type = 'html';
|
|
40
|
-
asset.setCode(render(
|
|
41
|
+
asset.setCode(render(pugConfig.locals));
|
|
41
42
|
|
|
42
43
|
return [asset];
|
|
43
44
|
},
|
|
44
|
-
});
|
|
45
|
+
}): Transformer);
|