@parcel/transformer-pug 2.0.0-nightly.149 → 2.0.0-nightly.1490
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 +35 -37
- package/package.json +10 -8
- package/src/PugTransformer.js +17 -19
package/lib/PugTransformer.js
CHANGED
|
@@ -4,55 +4,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function _path() {
|
|
8
|
+
const data = _interopRequireDefault(require("path"));
|
|
9
|
+
_path = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _plugin() {
|
|
15
|
+
const data = require("@parcel/plugin");
|
|
16
|
+
_plugin = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _pug() {
|
|
22
|
+
const data = _interopRequireDefault(require("pug"));
|
|
23
|
+
_pug = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
12
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
asset
|
|
29
|
+
var _default = exports.default = new (_plugin().Transformer)({
|
|
30
|
+
async loadConfig({
|
|
31
|
+
config
|
|
17
32
|
}) {
|
|
18
|
-
|
|
19
|
-
return
|
|
33
|
+
let configFile = await config.getConfig(['.pugrc', '.pugrc.js', '.pugrc.cjs', '.pugrc.mjs', 'pug.config.js', 'pug.config.cjs', 'pug.config.mjs']);
|
|
34
|
+
return configFile === null || configFile === void 0 ? void 0 : configFile.contents;
|
|
20
35
|
},
|
|
21
|
-
|
|
22
36
|
async transform({
|
|
23
37
|
asset,
|
|
24
|
-
config
|
|
25
|
-
options
|
|
38
|
+
config
|
|
26
39
|
}) {
|
|
27
|
-
|
|
28
|
-
return [asset];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const pug = await options.packageManager.require('pug', asset.filePath);
|
|
40
|
+
const pugConfig = config !== null && config !== void 0 ? config : {};
|
|
32
41
|
const content = await asset.getCode();
|
|
33
|
-
const render =
|
|
34
|
-
degug: true,
|
|
42
|
+
const render = _pug().default.compile(content, {
|
|
35
43
|
compileDebug: false,
|
|
36
|
-
basedir: _path.default.dirname(asset.filePath),
|
|
44
|
+
basedir: _path().default.dirname(asset.filePath),
|
|
37
45
|
filename: asset.filePath,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
filters: config.filters,
|
|
41
|
-
filterOptions: config.filterOptions,
|
|
42
|
-
filterAliases: config.filterAliases
|
|
46
|
+
...pugConfig,
|
|
47
|
+
pretty: pugConfig.pretty || false
|
|
43
48
|
});
|
|
44
|
-
|
|
45
49
|
for (let filePath of render.dependencies) {
|
|
46
|
-
|
|
47
|
-
filePath
|
|
48
|
-
});
|
|
50
|
+
asset.invalidateOnFileChange(filePath);
|
|
49
51
|
}
|
|
50
|
-
|
|
51
52
|
asset.type = 'html';
|
|
52
|
-
asset.setCode(render(
|
|
53
|
+
asset.setCode(render(pugConfig.locals));
|
|
53
54
|
return [asset];
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
exports.default = _default;
|
|
56
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-pug",
|
|
3
|
-
"version": "2.0.0-nightly.
|
|
3
|
+
"version": "2.0.0-nightly.1490+642d9cabc",
|
|
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": "
|
|
19
|
+
"node": ">= 12.0.0",
|
|
20
|
+
"parcel": "2.0.0-nightly.1488+642d9cabc"
|
|
17
21
|
},
|
|
18
22
|
"dependencies": {
|
|
19
|
-
"@parcel/plugin": "2.0.0-nightly.
|
|
20
|
-
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"pug": "^2.0.4"
|
|
23
|
+
"@parcel/plugin": "2.0.0-nightly.1490+642d9cabc",
|
|
24
|
+
"pug": "^3.0.2"
|
|
23
25
|
},
|
|
24
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "642d9cabc600bcb4681bbee0be168e05f5a8ffe5"
|
|
25
27
|
}
|
package/src/PugTransformer.js
CHANGED
|
@@ -2,43 +2,41 @@
|
|
|
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',
|
|
12
|
+
'.pugrc.cjs',
|
|
13
|
+
'.pugrc.mjs',
|
|
11
14
|
'pug.config.js',
|
|
15
|
+
'pug.config.cjs',
|
|
16
|
+
'pug.config.mjs',
|
|
12
17
|
]);
|
|
13
|
-
return config || {};
|
|
14
|
-
},
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return [asset];
|
|
19
|
-
}
|
|
19
|
+
return configFile?.contents;
|
|
20
|
+
},
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
async transform({asset, config}) {
|
|
23
|
+
const pugConfig = config ?? {};
|
|
22
24
|
const content = await asset.getCode();
|
|
23
25
|
const render = pug.compile(content, {
|
|
24
|
-
degug: true,
|
|
25
26
|
compileDebug: false,
|
|
26
27
|
basedir: path.dirname(asset.filePath),
|
|
27
28
|
filename: asset.filePath,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
filters: config.filters,
|
|
31
|
-
filterOptions: config.filterOptions,
|
|
32
|
-
filterAliases: config.filterAliases,
|
|
29
|
+
...pugConfig,
|
|
30
|
+
pretty: pugConfig.pretty || false,
|
|
33
31
|
});
|
|
34
32
|
|
|
35
33
|
for (let filePath of render.dependencies) {
|
|
36
|
-
|
|
34
|
+
asset.invalidateOnFileChange(filePath);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
asset.type = 'html';
|
|
40
|
-
asset.setCode(render(
|
|
38
|
+
asset.setCode(render(pugConfig.locals));
|
|
41
39
|
|
|
42
40
|
return [asset];
|
|
43
41
|
},
|
|
44
|
-
});
|
|
42
|
+
}): Transformer);
|