@atlaspack/transformer-posthtml 2.14.5-canary.17 → 2.14.5-canary.171

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/CHANGELOG.md CHANGED
@@ -1,5 +1,179 @@
1
1
  # @atlaspack/transformer-posthtml
2
2
 
3
+ ## 2.14.27
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/utils@2.18.4
9
+ - @atlaspack/plugin@2.14.27
10
+
11
+ ## 2.14.26
12
+
13
+ ### Patch Changes
14
+
15
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
16
+
17
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
18
+ - @atlaspack/plugin@2.14.26
19
+ - @atlaspack/utils@2.18.3
20
+
21
+ ## 2.14.25
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies []:
26
+ - @atlaspack/utils@2.18.2
27
+ - @atlaspack/plugin@2.14.25
28
+
29
+ ## 2.14.24
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies []:
34
+ - @atlaspack/utils@2.18.1
35
+ - @atlaspack/plugin@2.14.24
36
+
37
+ ## 2.14.23
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
42
+ - @atlaspack/utils@2.18.0
43
+ - @atlaspack/plugin@2.14.23
44
+
45
+ ## 2.14.22
46
+
47
+ ### Patch Changes
48
+
49
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
50
+
51
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
52
+ - @atlaspack/plugin@2.14.22
53
+ - @atlaspack/utils@2.17.4
54
+
55
+ ## 2.14.21
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies []:
60
+ - @atlaspack/utils@2.17.3
61
+ - @atlaspack/plugin@2.14.21
62
+
63
+ ## 2.14.20
64
+
65
+ ### Patch Changes
66
+
67
+ - [#702](https://github.com/atlassian-labs/atlaspack/pull/702) [`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa) Thanks [@alshdavid](https://github.com/alshdavid)! - Fixes to Flow types
68
+
69
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
70
+ - @atlaspack/plugin@2.14.20
71
+ - @atlaspack/utils@2.17.2
72
+
73
+ ## 2.14.19
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies []:
78
+ - @atlaspack/utils@2.17.1
79
+ - @atlaspack/plugin@2.14.19
80
+
81
+ ## 2.14.18
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
86
+ - @atlaspack/utils@2.17.0
87
+ - @atlaspack/plugin@2.14.18
88
+
89
+ ## 2.14.17
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies []:
94
+ - @atlaspack/utils@2.16.1
95
+ - @atlaspack/plugin@2.14.17
96
+
97
+ ## 2.14.16
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
102
+ - @atlaspack/utils@2.16.0
103
+ - @atlaspack/plugin@2.14.16
104
+
105
+ ## 2.14.15
106
+
107
+ ### Patch Changes
108
+
109
+ - Updated dependencies []:
110
+ - @atlaspack/utils@2.15.3
111
+ - @atlaspack/plugin@2.14.15
112
+
113
+ ## 2.14.14
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies []:
118
+ - @atlaspack/utils@2.15.2
119
+ - @atlaspack/plugin@2.14.14
120
+
121
+ ## 2.14.13
122
+
123
+ ### Patch Changes
124
+
125
+ - Updated dependencies []:
126
+ - @atlaspack/utils@2.15.1
127
+ - @atlaspack/plugin@2.14.13
128
+
129
+ ## 2.14.12
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
134
+ - @atlaspack/utils@2.15.0
135
+ - @atlaspack/plugin@2.14.12
136
+
137
+ ## 2.14.11
138
+
139
+ ### Patch Changes
140
+
141
+ - Updated dependencies []:
142
+ - @atlaspack/utils@2.14.11
143
+ - @atlaspack/plugin@2.14.11
144
+
145
+ ## 2.14.10
146
+
147
+ ### Patch Changes
148
+
149
+ - Updated dependencies []:
150
+ - @atlaspack/plugin@2.14.10
151
+ - @atlaspack/utils@2.14.10
152
+
153
+ ## 2.14.9
154
+
155
+ ### Patch Changes
156
+
157
+ - Updated dependencies []:
158
+ - @atlaspack/utils@2.14.9
159
+ - @atlaspack/plugin@2.14.9
160
+
161
+ ## 2.14.8
162
+
163
+ ### Patch Changes
164
+
165
+ - Updated dependencies []:
166
+ - @atlaspack/utils@2.14.8
167
+ - @atlaspack/plugin@2.14.8
168
+
169
+ ## 2.14.7
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies []:
174
+ - @atlaspack/utils@2.14.7
175
+ - @atlaspack/plugin@2.14.7
176
+
3
177
  ## 2.14.6
4
178
 
5
179
  ### Patch Changes
@@ -78,10 +78,17 @@ var _default = exports.default = new (_plugin().Transformer)({
78
78
  }
79
79
 
80
80
  // Load plugins. This must be done before adding dev dependencies so we auto install.
81
- let plugins = await (0, _loadPlugins.default)(configFile.contents.plugins, config.searchPath, options);
81
+ let plugins = await (0, _loadPlugins.default)(
82
+ // @ts-expect-error TS18046
83
+ configFile.contents.plugins, config.searchPath, options);
82
84
 
83
85
  // Now add dev dependencies so we invalidate when they change.
84
- let pluginArray = Array.isArray(configFile.contents.plugins) ? configFile.contents.plugins : Object.keys(configFile.contents.plugins);
86
+ // @ts-expect-error TS18046
87
+ let pluginArray = Array.isArray(configFile.contents.plugins) ?
88
+ // @ts-expect-error TS18046
89
+ configFile.contents.plugins :
90
+ // @ts-expect-error TS18046
91
+ Object.keys(configFile.contents.plugins);
85
92
  for (let p of pluginArray) {
86
93
  if (typeof p === 'string') {
87
94
  config.addDevDependency({
@@ -90,10 +97,14 @@ var _default = exports.default = new (_plugin().Transformer)({
90
97
  });
91
98
  }
92
99
  }
100
+
101
+ // @ts-expect-error TS18046
93
102
  configFile.contents.plugins = plugins;
94
103
 
95
104
  // tells posthtml that we have already called parse
105
+ // @ts-expect-error TS18046
96
106
  configFile.contents.skipParse = true;
107
+ // @ts-expect-error TS18046
97
108
  delete configFile.contents.render;
98
109
  return configFile.contents;
99
110
  }
@@ -129,11 +140,14 @@ var _default = exports.default = new (_plugin().Transformer)({
129
140
  return [asset];
130
141
  }
131
142
  let ast = (0, _nullthrows().default)(await asset.getAST());
143
+ // @ts-expect-error TS2339
132
144
  let res = await (0, _posthtml().default)(config.plugins).process(ast.program, {
133
145
  ...config,
146
+ // @ts-expect-error TS2353
134
147
  plugins: config.plugins
135
148
  });
136
149
  if (res.messages) {
150
+ // @ts-expect-error TS2339
137
151
  for (let {
138
152
  type,
139
153
  file: filePath
@@ -157,6 +171,7 @@ var _default = exports.default = new (_plugin().Transformer)({
157
171
  }) {
158
172
  return {
159
173
  content: (0, _posthtmlRender().render)(ast.program, {
174
+ // @ts-expect-error TS2322
160
175
  closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined
161
176
  })
162
177
  };
@@ -8,13 +8,16 @@ async function loadExternalPlugins(plugins, relative, options) {
8
8
  if (Array.isArray(plugins)) {
9
9
  return Promise.all(plugins.map(p => loadPlugin(p, relative, null, options.packageManager, options.shouldAutoInstall)).filter(Boolean));
10
10
  } else if (typeof plugins === 'object') {
11
- let mapPlugins = await Promise.all(Object.keys(plugins).map(p => loadPlugin(p, relative, plugins[p], options.packageManager, options.shouldAutoInstall)));
11
+ let _plugins = plugins;
12
+ let mapPlugins = await Promise.all(Object.keys(plugins).map(p => loadPlugin(p, relative, _plugins[p], options.packageManager, options.shouldAutoInstall)));
12
13
  return mapPlugins.filter(Boolean);
13
14
  } else {
14
15
  return [];
15
16
  }
16
17
  }
17
- async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall) {
18
+ async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall
19
+ // @ts-expect-error TS1064
20
+ ) {
18
21
  if (typeof pluginArg !== 'string') {
19
22
  return pluginArg;
20
23
  }
@@ -0,0 +1,3 @@
1
+ import { Transformer } from '@atlaspack/plugin';
2
+ declare const _default: Transformer<unknown>;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { FilePath, PluginOptions } from '@atlaspack/types-internal';
2
+ export default function loadExternalPlugins(plugins: Array<string> | {
3
+ readonly [pluginName: string]: unknown;
4
+ }, relative: FilePath, options: PluginOptions): Promise<Array<unknown>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-posthtml",
3
- "version": "2.14.5-canary.17+a1773d2a6",
3
+ "version": "2.14.5-canary.171+f0349a6b9",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,14 +9,15 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/PostHTMLTransformer.js",
13
- "source": "src/PostHTMLTransformer.js",
12
+ "main": "./lib/PostHTMLTransformer.js",
13
+ "source": "./src/PostHTMLTransformer.ts",
14
+ "types": "./lib/types/PostHTMLTransformer.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/plugin": "2.14.5-canary.17+a1773d2a6",
19
- "@atlaspack/utils": "2.14.5-canary.17+a1773d2a6",
19
+ "@atlaspack/plugin": "2.14.5-canary.171+f0349a6b9",
20
+ "@atlaspack/utils": "2.14.5-canary.171+f0349a6b9",
20
21
  "nullthrows": "^1.1.1",
21
22
  "posthtml": "^0.16.5",
22
23
  "posthtml-parser": "^0.10.1",
@@ -24,5 +25,9 @@
24
25
  "semver": "^7.5.2"
25
26
  },
26
27
  "type": "commonjs",
27
- "gitHead": "a1773d2a62d0ef7805ac7524621dcabcc1afe929"
28
+ "scripts": {
29
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
30
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
31
+ },
32
+ "gitHead": "f0349a6b9b04755088f121095ca6301a2ada3767"
28
33
  }
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  import {Transformer} from '@atlaspack/plugin';
4
2
 
5
3
  import path from 'path';
@@ -10,7 +8,7 @@ import nullthrows from 'nullthrows';
10
8
  import semver from 'semver';
11
9
  import loadPlugins from './loadPlugins';
12
10
 
13
- export default (new Transformer({
11
+ export default new Transformer({
14
12
  async loadConfig({config, options, logger}) {
15
13
  if (!config.isSource) {
16
14
  return;
@@ -44,15 +42,19 @@ export default (new Transformer({
44
42
 
45
43
  // Load plugins. This must be done before adding dev dependencies so we auto install.
46
44
  let plugins = await loadPlugins(
45
+ // @ts-expect-error TS18046
47
46
  configFile.contents.plugins,
48
47
  config.searchPath,
49
48
  options,
50
49
  );
51
50
 
52
51
  // Now add dev dependencies so we invalidate when they change.
52
+ // @ts-expect-error TS18046
53
53
  let pluginArray = Array.isArray(configFile.contents.plugins)
54
- ? configFile.contents.plugins
55
- : Object.keys(configFile.contents.plugins);
54
+ ? // @ts-expect-error TS18046
55
+ configFile.contents.plugins
56
+ : // @ts-expect-error TS18046
57
+ Object.keys(configFile.contents.plugins);
56
58
  for (let p of pluginArray) {
57
59
  if (typeof p === 'string') {
58
60
  config.addDevDependency({
@@ -62,10 +64,13 @@ export default (new Transformer({
62
64
  }
63
65
  }
64
66
 
67
+ // @ts-expect-error TS18046
65
68
  configFile.contents.plugins = plugins;
66
69
 
67
70
  // tells posthtml that we have already called parse
71
+ // @ts-expect-error TS18046
68
72
  configFile.contents.skipParse = true;
73
+ // @ts-expect-error TS18046
69
74
  delete configFile.contents.render;
70
75
 
71
76
  return configFile.contents;
@@ -99,12 +104,15 @@ export default (new Transformer({
99
104
  }
100
105
 
101
106
  let ast = nullthrows(await asset.getAST());
107
+ // @ts-expect-error TS2339
102
108
  let res = await posthtml(config.plugins).process(ast.program, {
103
109
  ...config,
110
+ // @ts-expect-error TS2353
104
111
  plugins: config.plugins,
105
112
  });
106
113
 
107
114
  if (res.messages) {
115
+ // @ts-expect-error TS2339
108
116
  for (let {type, file: filePath} of res.messages) {
109
117
  if (type === 'dependency') {
110
118
  asset.invalidateOnFileChange(filePath);
@@ -124,8 +132,9 @@ export default (new Transformer({
124
132
  generate({ast, asset}) {
125
133
  return {
126
134
  content: render(ast.program, {
135
+ // @ts-expect-error TS2322
127
136
  closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined,
128
137
  }),
129
138
  };
130
139
  },
131
- }): Transformer);
140
+ }) as Transformer<unknown>;
@@ -1,13 +1,18 @@
1
- // @flow
2
-
3
- import type {FilePath, PluginOptions} from '@atlaspack/types';
4
- import type {PackageManager} from '@atlaspack/package-manager';
1
+ import type {
2
+ FilePath,
3
+ PluginOptions,
4
+ PackageManager,
5
+ } from '@atlaspack/types-internal';
5
6
 
6
7
  export default async function loadExternalPlugins(
7
- plugins: Array<string> | {+[pluginName: string]: mixed, ...},
8
+ plugins:
9
+ | Array<string>
10
+ | {
11
+ readonly [pluginName: string]: unknown;
12
+ },
8
13
  relative: FilePath,
9
14
  options: PluginOptions,
10
- ): Promise<Array<mixed>> {
15
+ ): Promise<Array<unknown>> {
11
16
  if (Array.isArray(plugins)) {
12
17
  return Promise.all(
13
18
  plugins
@@ -42,12 +47,13 @@ export default async function loadExternalPlugins(
42
47
  }
43
48
 
44
49
  async function loadPlugin(
45
- pluginArg: string | Function,
50
+ pluginArg: string | any,
46
51
  relative: FilePath,
47
- options: mixed = {},
52
+ options: unknown | null | undefined = {},
48
53
  packageManager: PackageManager,
49
54
  shouldAutoInstall: boolean,
50
- ): mixed {
55
+ // @ts-expect-error TS1064
56
+ ): unknown {
51
57
  if (typeof pluginArg !== 'string') {
52
58
  return pluginArg;
53
59
  }
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }