@parcel/transformer-pug 2.0.0-nightly.142 → 2.0.0-nightly.1424

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.
@@ -4,55 +4,54 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
- var _path = _interopRequireDefault(require("path"));
9
-
10
- var _plugin = require("@parcel/plugin");
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
- var _default = new _plugin.Transformer({
15
- async getConfig({
16
- asset
29
+ var _default = new (_plugin().Transformer)({
30
+ async loadConfig({
31
+ config
17
32
  }) {
18
- const config = await asset.getConfig(['.pugrc', '.pugrc.js', 'pug.config.js']);
19
- return config || {};
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
- if (!config) {
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 = pug.compile(content, {
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
- pretty: config.pretty || false,
39
- doctype: config.doctype,
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
- await asset.addIncludedFile({
47
- filePath
48
- });
50
+ await asset.invalidateOnFileChange(filePath);
49
51
  }
50
-
51
52
  asset.type = 'html';
52
- asset.setCode(render(config.locals));
53
+ asset.setCode(render(pugConfig.locals));
53
54
  return [asset];
54
55
  }
55
-
56
56
  });
57
-
58
57
  exports.default = _default;
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@parcel/transformer-pug",
3
- "version": "2.0.0-nightly.142+c87c29dd",
3
+ "version": "2.0.0-nightly.1424+eeb3ba3de",
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": ">= 10.0.0",
16
- "parcel": "^2.0.0-alpha.1.1"
19
+ "node": ">= 12.0.0",
20
+ "parcel": "2.0.0-nightly.1422+eeb3ba3de"
17
21
  },
18
22
  "dependencies": {
19
- "@parcel/plugin": "2.0.0-nightly.142+c87c29dd"
20
- },
21
- "devDependencies": {
22
- "pug": "^2.0.4"
23
+ "@parcel/plugin": "2.0.0-nightly.1424+eeb3ba3de",
24
+ "pug": "^3.0.2"
23
25
  },
24
- "gitHead": "c87c29dd9ca09832e9677bb4d914d2e64bb2d5b8"
26
+ "gitHead": "eeb3ba3de6e4fe037cd4f5d73939fa6867faa1f4"
25
27
  }
@@ -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 getConfig({asset}) {
8
- const config = await asset.getConfig([
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
- async transform({asset, config, options}) {
17
- if (!config) {
18
- return [asset];
19
- }
19
+ return configFile?.contents;
20
+ },
20
21
 
21
- const pug = await options.packageManager.require('pug', asset.filePath);
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
- pretty: config.pretty || false,
29
- doctype: config.doctype,
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
- await asset.addIncludedFile({filePath});
34
+ await asset.invalidateOnFileChange(filePath);
37
35
  }
38
36
 
39
37
  asset.type = 'html';
40
- asset.setCode(render(config.locals));
38
+ asset.setCode(render(pugConfig.locals));
41
39
 
42
40
  return [asset];
43
41
  },
44
- });
42
+ }): Transformer);