@atlaspack/optimizer-htmlnano 2.14.5-canary.17 → 2.14.5-canary.170
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 +153 -0
- package/lib/HTMLNanoOptimizer.js +4 -4
- package/lib/svgMappings.js +1 -0
- package/lib/types/HTMLNanoOptimizer.d.ts +3 -0
- package/lib/types/svgMappings.d.ts +6 -0
- package/package.json +10 -5
- package/src/{HTMLNanoOptimizer.js → HTMLNanoOptimizer.ts} +9 -9
- package/src/{svgMappings.js → svgMappings.ts} +6 -3
- package/tsconfig.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,158 @@
|
|
|
1
1
|
# @atlaspack/optimizer-htmlnano
|
|
2
2
|
|
|
3
|
+
## 2.14.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atlaspack/plugin@2.14.27
|
|
9
|
+
|
|
10
|
+
## 2.14.26
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#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
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
|
|
17
|
+
- @atlaspack/plugin@2.14.26
|
|
18
|
+
|
|
19
|
+
## 2.14.25
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies []:
|
|
24
|
+
- @atlaspack/plugin@2.14.25
|
|
25
|
+
|
|
26
|
+
## 2.14.24
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies []:
|
|
31
|
+
- @atlaspack/plugin@2.14.24
|
|
32
|
+
|
|
33
|
+
## 2.14.23
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies []:
|
|
38
|
+
- @atlaspack/plugin@2.14.23
|
|
39
|
+
|
|
40
|
+
## 2.14.22
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- [#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
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
47
|
+
- @atlaspack/plugin@2.14.22
|
|
48
|
+
|
|
49
|
+
## 2.14.21
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies []:
|
|
54
|
+
- @atlaspack/plugin@2.14.21
|
|
55
|
+
|
|
56
|
+
## 2.14.20
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- [#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
|
|
61
|
+
|
|
62
|
+
- Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
|
|
63
|
+
- @atlaspack/plugin@2.14.20
|
|
64
|
+
|
|
65
|
+
## 2.14.19
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies []:
|
|
70
|
+
- @atlaspack/plugin@2.14.19
|
|
71
|
+
|
|
72
|
+
## 2.14.18
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies []:
|
|
77
|
+
- @atlaspack/plugin@2.14.18
|
|
78
|
+
|
|
79
|
+
## 2.14.17
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies []:
|
|
84
|
+
- @atlaspack/plugin@2.14.17
|
|
85
|
+
|
|
86
|
+
## 2.14.16
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- Updated dependencies []:
|
|
91
|
+
- @atlaspack/plugin@2.14.16
|
|
92
|
+
|
|
93
|
+
## 2.14.15
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- Updated dependencies []:
|
|
98
|
+
- @atlaspack/plugin@2.14.15
|
|
99
|
+
|
|
100
|
+
## 2.14.14
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- Updated dependencies []:
|
|
105
|
+
- @atlaspack/plugin@2.14.14
|
|
106
|
+
|
|
107
|
+
## 2.14.13
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- Updated dependencies []:
|
|
112
|
+
- @atlaspack/plugin@2.14.13
|
|
113
|
+
|
|
114
|
+
## 2.14.12
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies []:
|
|
119
|
+
- @atlaspack/plugin@2.14.12
|
|
120
|
+
|
|
121
|
+
## 2.14.11
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Updated dependencies []:
|
|
126
|
+
- @atlaspack/plugin@2.14.11
|
|
127
|
+
|
|
128
|
+
## 2.14.10
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Updated dependencies []:
|
|
133
|
+
- @atlaspack/plugin@2.14.10
|
|
134
|
+
|
|
135
|
+
## 2.14.9
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies []:
|
|
140
|
+
- @atlaspack/plugin@2.14.9
|
|
141
|
+
|
|
142
|
+
## 2.14.8
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- Updated dependencies []:
|
|
147
|
+
- @atlaspack/plugin@2.14.8
|
|
148
|
+
|
|
149
|
+
## 2.14.7
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- Updated dependencies []:
|
|
154
|
+
- @atlaspack/plugin@2.14.7
|
|
155
|
+
|
|
3
156
|
## 2.14.6
|
|
4
157
|
|
|
5
158
|
### Patch Changes
|
package/lib/HTMLNanoOptimizer.js
CHANGED
|
@@ -34,6 +34,8 @@ function _path() {
|
|
|
34
34
|
}
|
|
35
35
|
var _svgMappings = require("./svgMappings");
|
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
// @ts-expect-error TS2724
|
|
38
|
+
// @ts-expect-error TS7016
|
|
37
39
|
var _default = exports.default = new (_plugin().Optimizer)({
|
|
38
40
|
async loadConfig({
|
|
39
41
|
config,
|
|
@@ -60,8 +62,6 @@ var _default = exports.default = new (_plugin().Optimizer)({
|
|
|
60
62
|
throw new Error('HTMLNanoOptimizer: Only string contents are currently supported');
|
|
61
63
|
}
|
|
62
64
|
const clonedConfig = config || {};
|
|
63
|
-
|
|
64
|
-
// $FlowFixMe
|
|
65
65
|
const presets = _htmlnano().default.presets;
|
|
66
66
|
const preset = typeof clonedConfig.preset === 'string' ? presets[clonedConfig.preset] : {};
|
|
67
67
|
delete clonedConfig.preset;
|
|
@@ -103,12 +103,13 @@ var _default = exports.default = new (_plugin().Optimizer)({
|
|
|
103
103
|
|
|
104
104
|
let plugins = [(0, _htmlnano().default)(htmlNanoConfig)];
|
|
105
105
|
|
|
106
|
-
//
|
|
106
|
+
// @ts-expect-error TS18046
|
|
107
107
|
if (htmlNanoConfig.minifySvg !== false) {
|
|
108
108
|
plugins.unshift(mapSVG);
|
|
109
109
|
}
|
|
110
110
|
return {
|
|
111
111
|
contents: (await (0, _posthtml().default)(plugins).process(contents, {
|
|
112
|
+
// @ts-expect-error TS2353
|
|
112
113
|
xmlMode: bundle.type === 'xhtml',
|
|
113
114
|
closingSingleTag: bundle.type === 'xhtml' ? 'slash' : undefined
|
|
114
115
|
})).html
|
|
@@ -120,7 +121,6 @@ var _default = exports.default = new (_plugin().Optimizer)({
|
|
|
120
121
|
function mapSVG(node, inSVG = false) {
|
|
121
122
|
if (Array.isArray(node)) {
|
|
122
123
|
for (let i = 0; i < node.length; i++) {
|
|
123
|
-
// $FlowFixMe
|
|
124
124
|
node[i] = mapSVG(node[i], inSVG);
|
|
125
125
|
}
|
|
126
126
|
} else if (node && typeof node === 'object') {
|
package/lib/svgMappings.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SVG_TAG_NAMES = exports.SVG_ATTRS = void 0;
|
|
7
7
|
// Based on parse5: https://github.com/inikulin/parse5/blob/252819607421a5741cf745bb60c404f023531b0d/packages/parse5/lib/common/foreign-content.js#L54
|
|
8
|
+
|
|
8
9
|
const SVG_TAG_NAMES = exports.SVG_TAG_NAMES = {
|
|
9
10
|
altglyph: 'altGlyph',
|
|
10
11
|
altglyphdef: 'altGlyphDef',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/optimizer-htmlnano",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.170+c940954d2",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,18 +9,23 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "lib/HTMLNanoOptimizer.js",
|
|
13
|
-
"source": "src/HTMLNanoOptimizer.
|
|
12
|
+
"main": "./lib/HTMLNanoOptimizer.js",
|
|
13
|
+
"source": "./src/HTMLNanoOptimizer.ts",
|
|
14
|
+
"types": "./lib/types/HTMLNanoOptimizer.d.ts",
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">= 16.0.0"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
19
|
+
"@atlaspack/plugin": "2.14.5-canary.170+c940954d2",
|
|
19
20
|
"htmlnano": "^2.0.0",
|
|
20
21
|
"nullthrows": "^1.1.1",
|
|
21
22
|
"posthtml": "^0.16.5",
|
|
22
23
|
"svgo": "^2.4.0"
|
|
23
24
|
},
|
|
24
25
|
"type": "commonjs",
|
|
25
|
-
"
|
|
26
|
+
"scripts": {
|
|
27
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
28
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "c940954d27d657c3c93cd328dfb394778da46eab"
|
|
26
31
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
// @
|
|
1
|
+
// @ts-expect-error TS2724
|
|
2
2
|
import type {PostHTMLNode} from 'posthtml';
|
|
3
3
|
|
|
4
|
+
// @ts-expect-error TS7016
|
|
4
5
|
import htmlnano from 'htmlnano';
|
|
5
6
|
import {Optimizer} from '@atlaspack/plugin';
|
|
6
7
|
import posthtml from 'posthtml';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import {SVG_ATTRS, SVG_TAG_NAMES} from './svgMappings';
|
|
9
10
|
|
|
10
|
-
export default
|
|
11
|
+
export default new Optimizer({
|
|
11
12
|
async loadConfig({config, options}) {
|
|
12
13
|
let userConfig = await config.getConfigFrom(
|
|
13
14
|
path.join(options.projectRoot, 'index.html'),
|
|
@@ -39,17 +40,16 @@ export default (new Optimizer({
|
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
const clonedConfig = config || {};
|
|
43
|
+
const clonedConfig: Record<any, any> = config || {};
|
|
43
44
|
|
|
44
|
-
// $FlowFixMe
|
|
45
45
|
const presets = htmlnano.presets;
|
|
46
|
-
const preset =
|
|
46
|
+
const preset: Record<any, any> =
|
|
47
47
|
typeof clonedConfig.preset === 'string'
|
|
48
48
|
? presets[clonedConfig.preset]
|
|
49
49
|
: {};
|
|
50
50
|
delete clonedConfig.preset;
|
|
51
51
|
|
|
52
|
-
const htmlNanoConfig = {
|
|
52
|
+
const htmlNanoConfig: unknown = {
|
|
53
53
|
// Inline <script> and <style> elements, and style attributes are already
|
|
54
54
|
// minified before they are re-inserted by the packager.
|
|
55
55
|
minifyJs: false,
|
|
@@ -89,7 +89,7 @@ export default (new Optimizer({
|
|
|
89
89
|
|
|
90
90
|
let plugins = [htmlnano(htmlNanoConfig)];
|
|
91
91
|
|
|
92
|
-
//
|
|
92
|
+
// @ts-expect-error TS18046
|
|
93
93
|
if (htmlNanoConfig.minifySvg !== false) {
|
|
94
94
|
plugins.unshift(mapSVG);
|
|
95
95
|
}
|
|
@@ -97,13 +97,14 @@ export default (new Optimizer({
|
|
|
97
97
|
return {
|
|
98
98
|
contents: (
|
|
99
99
|
await posthtml(plugins).process(contents, {
|
|
100
|
+
// @ts-expect-error TS2353
|
|
100
101
|
xmlMode: bundle.type === 'xhtml',
|
|
101
102
|
closingSingleTag: bundle.type === 'xhtml' ? 'slash' : undefined,
|
|
102
103
|
})
|
|
103
104
|
).html,
|
|
104
105
|
};
|
|
105
106
|
},
|
|
106
|
-
})
|
|
107
|
+
}) as Optimizer<unknown, unknown>;
|
|
107
108
|
|
|
108
109
|
// HTML tags and attributes are case insensitive. The HTML transformer normalizes them so it can
|
|
109
110
|
// more easily process any case. But SVGO requires case sensitive tags and attributes to work correctly.
|
|
@@ -114,7 +115,6 @@ function mapSVG(
|
|
|
114
115
|
) {
|
|
115
116
|
if (Array.isArray(node)) {
|
|
116
117
|
for (let i = 0; i < node.length; i++) {
|
|
117
|
-
// $FlowFixMe
|
|
118
118
|
node[i] = mapSVG(node[i], inSVG);
|
|
119
119
|
}
|
|
120
120
|
} else if (node && typeof node === 'object') {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
// Based on parse5: https://github.com/inikulin/parse5/blob/252819607421a5741cf745bb60c404f023531b0d/packages/parse5/lib/common/foreign-content.js#L54
|
|
3
2
|
|
|
4
|
-
export const SVG_TAG_NAMES: {
|
|
3
|
+
export const SVG_TAG_NAMES: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
} = {
|
|
5
6
|
altglyph: 'altGlyph',
|
|
6
7
|
altglyphdef: 'altGlyphDef',
|
|
7
8
|
altglyphitem: 'altGlyphItem',
|
|
@@ -40,7 +41,9 @@ export const SVG_TAG_NAMES: {|[string]: string|} = {
|
|
|
40
41
|
textpath: 'textPath',
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
export const SVG_ATTRS: {
|
|
44
|
+
export const SVG_ATTRS: {
|
|
45
|
+
[key: string]: string;
|
|
46
|
+
} = {
|
|
44
47
|
attributename: 'attributeName',
|
|
45
48
|
attributetype: 'attributeType',
|
|
46
49
|
basefrequency: 'baseFrequency',
|
package/tsconfig.json
ADDED