@atlaspack/transformer-html 2.12.1-canary.3417 → 2.12.1-canary.3418
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/package.json +7 -7
- package/test/HTMLTransformer.test.js +37 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaspack/transformer-html",
|
3
|
-
"version": "2.12.1-canary.
|
3
|
+
"version": "2.12.1-canary.3418+49a56fea2",
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -16,12 +16,12 @@
|
|
16
16
|
"source": "src/HTMLTransformer.js",
|
17
17
|
"engines": {
|
18
18
|
"node": ">= 16.0.0",
|
19
|
-
"parcel": "2.12.1-canary.
|
19
|
+
"parcel": "2.12.1-canary.3418+49a56fea2"
|
20
20
|
},
|
21
21
|
"dependencies": {
|
22
|
-
"@atlaspack/diagnostic": "2.12.1-canary.
|
23
|
-
"@atlaspack/plugin": "2.12.1-canary.
|
24
|
-
"@atlaspack/rust": "2.12.1-canary.
|
22
|
+
"@atlaspack/diagnostic": "2.12.1-canary.3418+49a56fea2",
|
23
|
+
"@atlaspack/plugin": "2.12.1-canary.3418+49a56fea2",
|
24
|
+
"@atlaspack/rust": "2.12.1-canary.3418+49a56fea2",
|
25
25
|
"nullthrows": "^1.1.1",
|
26
26
|
"posthtml": "^0.16.5",
|
27
27
|
"posthtml-parser": "^0.10.1",
|
@@ -30,7 +30,7 @@
|
|
30
30
|
"srcset": "4"
|
31
31
|
},
|
32
32
|
"devDependencies": {
|
33
|
-
"@atlaspack/core": "2.12.1-canary.
|
33
|
+
"@atlaspack/core": "2.12.1-canary.3418+49a56fea2"
|
34
34
|
},
|
35
|
-
"gitHead": "
|
35
|
+
"gitHead": "49a56fea20468bd4cb26ecf69f9b3a200986a35b"
|
36
36
|
}
|
@@ -47,6 +47,10 @@ async function runTestTransform(
|
|
47
47
|
return options.supportsEsmodules;
|
48
48
|
},
|
49
49
|
},
|
50
|
+
addDependency(specifier, specifierType) {
|
51
|
+
dependencies.push({specifier, specifierType});
|
52
|
+
return 'dependency-id';
|
53
|
+
},
|
50
54
|
};
|
51
55
|
|
52
56
|
const transformInput = {
|
@@ -68,6 +72,7 @@ function normalizeDependencies(dependencies) {
|
|
68
72
|
opts: {
|
69
73
|
...dependency.opts,
|
70
74
|
env: {
|
75
|
+
// $FlowFixMe
|
71
76
|
...dependency.opts.env,
|
72
77
|
loc: null,
|
73
78
|
},
|
@@ -75,6 +80,17 @@ function normalizeDependencies(dependencies) {
|
|
75
80
|
}));
|
76
81
|
}
|
77
82
|
|
83
|
+
function normalizeAssets(assets) {
|
84
|
+
return assets.map(asset => {
|
85
|
+
// $FlowFixMe
|
86
|
+
return {
|
87
|
+
...asset,
|
88
|
+
env: null,
|
89
|
+
meta: null,
|
90
|
+
};
|
91
|
+
});
|
92
|
+
}
|
93
|
+
|
78
94
|
describe('HTMLTransformer', () => {
|
79
95
|
it('transform simple script tag', async () => {
|
80
96
|
const code = `
|
@@ -114,6 +130,27 @@ describe('HTMLTransformer', () => {
|
|
114
130
|
assert.deepEqual(transformResult, [inputAsset]);
|
115
131
|
});
|
116
132
|
|
133
|
+
it('transforms simple inline script', async () => {
|
134
|
+
const code = `
|
135
|
+
<html>
|
136
|
+
<body>
|
137
|
+
<script>console.log('blah'); require('path');</script>
|
138
|
+
</body>
|
139
|
+
</html>
|
140
|
+
`;
|
141
|
+
const {transformResult, inputAsset} = await runTestTransform(code);
|
142
|
+
assert(transformResult.includes(inputAsset));
|
143
|
+
const assets = normalizeAssets(transformResult);
|
144
|
+
assert.deepEqual(assets[1], {
|
145
|
+
type: 'js',
|
146
|
+
content: "console.log('blah'); require('path');",
|
147
|
+
uniqueKey: 'a8a37984d2e520b9',
|
148
|
+
bundleBehavior: 'inline',
|
149
|
+
env: null,
|
150
|
+
meta: null,
|
151
|
+
});
|
152
|
+
});
|
153
|
+
|
117
154
|
it('we will get one dependency per asset', async () => {
|
118
155
|
const code = `
|
119
156
|
<html>
|