@parcel/transformer-pug 2.0.0-beta.1 → 2.0.0-nightly.1002

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.
@@ -5,69 +5,72 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _path = _interopRequireDefault(require("path"));
8
+ function _path() {
9
+ const data = _interopRequireDefault(require("path"));
9
10
 
10
- var _plugin = require("@parcel/plugin");
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({
40
+ var _default = new (_plugin().Transformer)({
15
41
  async loadConfig({
16
42
  config
17
43
  }) {
18
44
  let configFile = await config.getConfig(['.pugrc', '.pugrc.js', 'pug.config.js']);
19
45
 
20
46
  if (configFile) {
21
- let isJavascript = _path.default.extname(configFile.filePath) === '.js';
47
+ let isJavascript = _path().default.extname(configFile.filePath) === '.js';
22
48
 
23
49
  if (isJavascript) {
24
- config.shouldInvalidateOnStartup();
25
- config.shouldReload();
50
+ config.invalidateOnStartup();
26
51
  }
27
52
 
28
- config.setResult({
29
- contents: configFile.contents,
30
- isSerialisable: !isJavascript
31
- });
32
- }
33
- },
34
-
35
- preSerializeConfig({
36
- config
37
- }) {
38
- if (!config.result) return; // Ensure we dont try to serialise functions
39
-
40
- if (!config.result.isSerialisable) {
41
- config.result.contents = {};
53
+ return configFile.contents;
42
54
  }
43
55
  },
44
56
 
45
57
  async transform({
46
58
  asset,
47
- config,
48
- options
59
+ config
49
60
  }) {
50
- const pugConfig = config ? config.contents : {};
51
- const pug = await options.packageManager.require('pug', asset.filePath, {
52
- autoinstall: options.autoinstall
53
- });
61
+ const pugConfig = config !== null && config !== void 0 ? config : {};
54
62
  const content = await asset.getCode();
55
- const render = pug.compile(content, {
56
- degug: true,
63
+
64
+ const render = _pug().default.compile(content, {
57
65
  compileDebug: false,
58
- basedir: _path.default.dirname(asset.filePath),
66
+ basedir: _path().default.dirname(asset.filePath),
59
67
  filename: asset.filePath,
60
- pretty: pugConfig.pretty || false,
61
- doctype: pugConfig.doctype,
62
- filters: pugConfig.filters,
63
- filterOptions: pugConfig.filterOptions,
64
- filterAliases: pugConfig.filterAliases
68
+ ...pugConfig,
69
+ pretty: pugConfig.pretty || false
65
70
  });
66
71
 
67
72
  for (let filePath of render.dependencies) {
68
- await asset.addIncludedFile({
69
- filePath
70
- });
73
+ await asset.invalidateOnFileChange(filePath);
71
74
  }
72
75
 
73
76
  asset.type = 'html';
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@parcel/transformer-pug",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-nightly.1002+5530a6ef",
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.1000+5530a6ef"
17
21
  },
18
22
  "dependencies": {
19
- "@parcel/plugin": "2.0.0-beta.1"
20
- },
21
- "devDependencies": {
22
- "pug": "^2.0.4"
23
+ "@parcel/plugin": "2.0.0-nightly.1002+5530a6ef",
24
+ "pug": "^3.0.2"
23
25
  },
24
- "gitHead": "74335525be92e23bac4ed1bf30595443cfb238e3"
26
+ "gitHead": "5530a6eff8b619873353baeb0457ae4ec591e9fa"
25
27
  }
@@ -2,8 +2,9 @@
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
+ export default (new Transformer({
7
8
  async loadConfig({config}) {
8
9
  let configFile = await config.getConfig([
9
10
  '.pugrc',
@@ -14,46 +15,26 @@ export default new Transformer({
14
15
  if (configFile) {
15
16
  let isJavascript = path.extname(configFile.filePath) === '.js';
16
17
  if (isJavascript) {
17
- config.shouldInvalidateOnStartup();
18
- config.shouldReload();
18
+ config.invalidateOnStartup();
19
19
  }
20
20
 
21
- config.setResult({
22
- contents: configFile.contents,
23
- isSerialisable: !isJavascript,
24
- });
21
+ return configFile.contents;
25
22
  }
26
23
  },
27
24
 
28
- preSerializeConfig({config}) {
29
- if (!config.result) return;
30
-
31
- // Ensure we dont try to serialise functions
32
- if (!config.result.isSerialisable) {
33
- config.result.contents = {};
34
- }
35
- },
36
-
37
- async transform({asset, config, options}) {
38
- const pugConfig = config ? config.contents : {};
39
- const pug = await options.packageManager.require('pug', asset.filePath, {
40
- autoinstall: options.autoinstall,
41
- });
25
+ async transform({asset, config}) {
26
+ const pugConfig = config ?? {};
42
27
  const content = await asset.getCode();
43
28
  const render = pug.compile(content, {
44
- degug: true,
45
29
  compileDebug: false,
46
30
  basedir: path.dirname(asset.filePath),
47
31
  filename: asset.filePath,
32
+ ...pugConfig,
48
33
  pretty: pugConfig.pretty || false,
49
- doctype: pugConfig.doctype,
50
- filters: pugConfig.filters,
51
- filterOptions: pugConfig.filterOptions,
52
- filterAliases: pugConfig.filterAliases,
53
34
  });
54
35
 
55
36
  for (let filePath of render.dependencies) {
56
- await asset.addIncludedFile({filePath});
37
+ await asset.invalidateOnFileChange(filePath);
57
38
  }
58
39
 
59
40
  asset.type = 'html';
@@ -61,4 +42,4 @@ export default new Transformer({
61
42
 
62
43
  return [asset];
63
44
  },
64
- });
45
+ }): Transformer);