@astrojs/compiler 0.2.5 → 0.2.9

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,24 @@
1
1
  # @astrojs/compiler
2
2
 
3
+ ## 0.2.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 3ea8d8c: Fix for string interpolation within titles
8
+ - ef7cb1e: Fixes bug with textContent containing apostrophe character
9
+
10
+ ## 0.2.8
11
+
12
+ ### Patch Changes
13
+
14
+ - b2d5564: Fixes wasm build
15
+
16
+ ## 0.2.6
17
+
18
+ ### Patch Changes
19
+
20
+ - fix small issue with `preprocessStyle` handling of `null` or `undefined`
21
+
3
22
  ## 0.2.5
4
23
 
5
24
  ### Patch Changes
package/astro.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/compiler",
3
3
  "type": "module",
4
- "version": "0.2.5",
4
+ "version": "0.2.9",
5
5
  "scripts": {
6
6
  "build": "tsc -p ."
7
7
  },
@@ -0,0 +1,65 @@
1
+ /* eslint-disable no-console */
2
+
3
+ import { transform } from '@astrojs/compiler';
4
+
5
+ const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
6
+
7
+ async function run() {
8
+
9
+ let i = 0;
10
+ const result = await transform(
11
+ `---
12
+ let value = 'world';
13
+ ---
14
+
15
+ <style lang="scss" define:vars={{ a: 0 }}>
16
+ div {
17
+ color: red;
18
+ }
19
+ </style>
20
+
21
+ <div>Hello world!</div>
22
+
23
+ <div>Ahhh</div>
24
+
25
+ <style lang="scss">
26
+ div {
27
+ color: green;
28
+ }
29
+ </style>
30
+ `,
31
+ {
32
+ sourcemap: true,
33
+ // HOLY CRAP THIS ACTUALLY WORKS!
34
+ preprocessStyle: async (value, attrs) => {
35
+ let x = i++;
36
+ if (!attrs.lang) {
37
+ return null;
38
+ }
39
+ // console.log(`Starting to preprocess style ${x} as ${attrs.lang}`);
40
+ // await sleep(3000);
41
+ // console.log(`Finished preprocessing ${x}`);
42
+ return { code: value.replace('color', 'background') };
43
+ },
44
+ }
45
+ );
46
+ // console.log(result);
47
+
48
+ // test
49
+ if (!result.code.includes('background:red')) {
50
+ throw new Error(`Styles didn’t transform as expected. Expected "background:red" to be present.`);
51
+ }
52
+
53
+ if (!result.code.includes('background:green')) {
54
+ throw new Error(`Styles didn’t transform as expected. Expected "background:green" to be present.`);
55
+ }
56
+
57
+ // const start = performance.now()
58
+ // const html = await compile(template);
59
+ // const end = performance.now()
60
+
61
+ // console.log('Compiled in ' + (start - end).toFixed(1) + 'ms');
62
+ // console.log(html);
63
+ }
64
+
65
+ await run();
@@ -0,0 +1,29 @@
1
+ /* eslint-disable no-console */
2
+ import { transform } from '@astrojs/compiler';
3
+
4
+ const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
5
+
6
+ async function run() {
7
+ let i = 0;
8
+ const result = await transform(
9
+ `<div xmlns:happy="https://example.com/schemas/happy">
10
+ <img src="jolly.avif" happy:smile="sweet"/>
11
+ </div>
12
+ `,
13
+ {
14
+ site: undefined,
15
+ sourcefile: '/Users/matthew/dev/astro/packages/astro/test/fixtures/astro-attrs/src/pages/namespaced.astro',
16
+ sourcemap: 'both',
17
+ internalURL: 'astro/internal',
18
+ preprocessStyle: async (value, attrs) => {
19
+ return null;
20
+ },
21
+ }
22
+ );
23
+
24
+ if(result.code[0] === '\x00') {
25
+ throw new Error('Corrupt output');
26
+ }
27
+ }
28
+
29
+ await run().catch(err => { console.error(err); process.exit(1); });
package/test/test.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import './basic.test.mjs';
2
+ import './output.test.mjs';
package/test.js DELETED
@@ -1,55 +0,0 @@
1
- /* eslint-disable no-console */
2
-
3
- const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
4
-
5
- (async () => {
6
- const { transform } = await import('@astrojs/compiler');
7
- let i = 0;
8
- try {
9
- const result = await transform(
10
- `---
11
- let value = 'world';
12
- ---
13
-
14
- <style lang="scss" define:vars={{ a: 0 }}>
15
- div {
16
- color: red;
17
- }
18
- </style>
19
-
20
- <div>Hello world!</div>
21
-
22
- <div>Ahhh</div>
23
-
24
- <style lang="scss">
25
- div {
26
- color: green;
27
- }
28
- </style>
29
- `,
30
- {
31
- sourcemap: true,
32
- // HOLY CRAP THIS ACTUALLY WORKS!
33
- preprocessStyle: async (value, attrs) => {
34
- let x = i++;
35
- if (!attrs.lang) {
36
- return null;
37
- }
38
- console.log(`Starting to preprocess style ${x} as ${attrs.lang}`);
39
- await sleep(3000);
40
- console.log(`Finished preprocessing ${x}`);
41
- return { code: value.replace('color', 'background') };
42
- },
43
- }
44
- );
45
- console.log(result);
46
- } catch (e) {
47
- console.log(e);
48
- }
49
- // const start = performance.now()
50
- // const html = await compile(template);
51
- // const end = performance.now()
52
-
53
- // console.log('Compiled in ' + (start - end).toFixed(1) + 'ms');
54
- // console.log(html);
55
- })();