@ixon-cdk/svelte-builder 1.21.0 → 1.22.0-next.0
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/browser.js +24 -18
- package/index.js +8 -7
- package/package.json +13 -9
package/browser.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { build, normalizePath } from 'vite';
|
|
6
|
+
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
7
|
+
import { sveltePreprocess } from 'svelte-preprocess';
|
|
8
|
+
import typescript from '@rollup/plugin-typescript';
|
|
9
|
+
import {
|
|
8
10
|
dirContains,
|
|
9
11
|
getRootDir,
|
|
10
12
|
pascalCase,
|
|
@@ -14,7 +16,7 @@ const {
|
|
|
14
16
|
writeDemoFile,
|
|
15
17
|
copyAssets,
|
|
16
18
|
watchAssets,
|
|
17
|
-
}
|
|
19
|
+
} from '@ixon-cdk/core';
|
|
18
20
|
|
|
19
21
|
async function _build(
|
|
20
22
|
inputFile,
|
|
@@ -30,7 +32,10 @@ async function _build(
|
|
|
30
32
|
|
|
31
33
|
// temporary entry file
|
|
32
34
|
const date = new Date().getTime();
|
|
33
|
-
const entryFileName = path.join(
|
|
35
|
+
const entryFileName = path.join(
|
|
36
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
37
|
+
`__temp_entry-${tag}-${date}.js`,
|
|
38
|
+
);
|
|
34
39
|
const componentStatic = pascalCase(tag);
|
|
35
40
|
const relativeInputPath = path.relative(
|
|
36
41
|
path.dirname(entryFileName),
|
|
@@ -38,7 +43,7 @@ async function _build(
|
|
|
38
43
|
);
|
|
39
44
|
const entryFileContent = `import ${componentStatic} from '${normalizePath(
|
|
40
45
|
relativeInputPath,
|
|
41
|
-
)}';\
|
|
46
|
+
)}';\ncustomElements.define('${tag}', ${componentStatic}.element);\n`;
|
|
42
47
|
fs.writeFileSync(entryFileName, entryFileContent, {
|
|
43
48
|
encoding: 'utf8',
|
|
44
49
|
flag: 'w',
|
|
@@ -73,10 +78,8 @@ async function _build(
|
|
|
73
78
|
compilerOptions: {
|
|
74
79
|
customElement: true,
|
|
75
80
|
dev: !production,
|
|
76
|
-
immutable: true,
|
|
77
|
-
tag,
|
|
78
81
|
},
|
|
79
|
-
preprocess:
|
|
82
|
+
preprocess: sveltePreprocess({ sourceMap }),
|
|
80
83
|
}),
|
|
81
84
|
],
|
|
82
85
|
};
|
|
@@ -101,7 +104,7 @@ async function _build(
|
|
|
101
104
|
|
|
102
105
|
// build
|
|
103
106
|
process.on('uncaughtException', () => {
|
|
104
|
-
//
|
|
107
|
+
// NOOP: builder will show an error
|
|
105
108
|
});
|
|
106
109
|
|
|
107
110
|
if (!watch) {
|
|
@@ -139,8 +142,11 @@ async function _build(
|
|
|
139
142
|
function typeCheck({ tsConfig, inputDir }) {
|
|
140
143
|
return {
|
|
141
144
|
writeBundle() {
|
|
142
|
-
const childProcess =
|
|
143
|
-
|
|
145
|
+
const childProcess = spawn(
|
|
146
|
+
path.join(
|
|
147
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
148
|
+
'./node_modules/svelte-check/bin/svelte-check',
|
|
149
|
+
),
|
|
144
150
|
['--tsconfig', tsConfig],
|
|
145
151
|
{
|
|
146
152
|
stdio: ['ignore', 'inherit', 'inherit'],
|
|
@@ -157,7 +163,7 @@ function typeCheck({ tsConfig, inputDir }) {
|
|
|
157
163
|
};
|
|
158
164
|
}
|
|
159
165
|
|
|
160
|
-
|
|
166
|
+
export default function runBuild(
|
|
161
167
|
inputFile,
|
|
162
168
|
outputFile,
|
|
163
169
|
tag,
|
|
@@ -175,4 +181,4 @@ module.exports = function runBuild(
|
|
|
175
181
|
watch,
|
|
176
182
|
sourceMap,
|
|
177
183
|
);
|
|
178
|
-
}
|
|
184
|
+
}
|
package/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getArgv, getRootDir, logErrorMessage } from '@ixon-cdk/core';
|
|
4
|
+
import isPotentialCustomElementName from 'is-potential-custom-element-name';
|
|
5
|
+
import runBrowserBuild from './browser.js';
|
|
5
6
|
|
|
6
|
-
function main() {
|
|
7
|
+
async function main() {
|
|
7
8
|
const argv = getArgv();
|
|
8
9
|
const buildTarget = argv._[0];
|
|
9
10
|
const tag = argv._[1];
|
|
@@ -27,13 +28,13 @@ function main() {
|
|
|
27
28
|
|
|
28
29
|
if (!isPotentialCustomElementName(tag)) {
|
|
29
30
|
logErrorMessage(
|
|
30
|
-
`Custom element name '${tag}' is invalid. See https://html.spec.whatwg.org/multipage/custom-elements.html#
|
|
31
|
+
`Custom element name '${tag}' is invalid. See https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name`,
|
|
31
32
|
);
|
|
32
33
|
process.exit(1);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
if (buildTarget === 'browser') {
|
|
36
|
-
|
|
37
|
+
await runBrowserBuild(input, output, tag, assets, true, watch, sourceMap);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixon-cdk/svelte-builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0-next.0",
|
|
4
4
|
"description": "",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js"
|
|
9
|
+
},
|
|
6
10
|
"author": "",
|
|
7
11
|
"license": "ISC",
|
|
8
12
|
"dependencies": {
|
|
9
|
-
"@rollup/plugin-typescript": "^
|
|
10
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
11
|
-
"@tsconfig/svelte": "^5.0.
|
|
13
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
14
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
15
|
+
"@tsconfig/svelte": "^5.0.6",
|
|
12
16
|
"is-potential-custom-element-name": "^1.0.1",
|
|
13
17
|
"sass": "^1.58.3",
|
|
14
|
-
"svelte": "^
|
|
15
|
-
"svelte-check": "^3.
|
|
16
|
-
"svelte-preprocess": "^
|
|
17
|
-
"vite": "^
|
|
18
|
+
"svelte": "^5.45.8",
|
|
19
|
+
"svelte-check": "^4.3.4",
|
|
20
|
+
"svelte-preprocess": "^6.0.3",
|
|
21
|
+
"vite": "^7.2.6"
|
|
18
22
|
},
|
|
19
23
|
"peerDependencies": {
|
|
20
|
-
"@ixon-cdk/core": "^1.
|
|
24
|
+
"@ixon-cdk/core": "^1.22.0-next.0"
|
|
21
25
|
}
|
|
22
26
|
}
|