@embeddable.com/sdk-core 4.0.0-next.2 → 4.0.1-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/lib/index.esm.js +61 -19
- package/lib/index.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/buildTypes.test.ts +46 -0
- package/src/buildTypes.ts +3 -0
- package/src/defineConfig.test.ts +7 -7
- package/src/dev.test.ts +1554 -41
- package/src/dev.ts +67 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddable.com/sdk-core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-next.0",
|
|
4
4
|
"description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embeddable",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@embeddable.com/core": "2.10.
|
|
44
|
-
"@embeddable.com/sdk-utils": "0.8.1
|
|
43
|
+
"@embeddable.com/core": "2.10.6-next.0",
|
|
44
|
+
"@embeddable.com/sdk-utils": "0.8.1",
|
|
45
45
|
"@inquirer/prompts": "^7.2.1",
|
|
46
46
|
"@stencil/core": "^4.23.0",
|
|
47
47
|
"@swc-node/register": "^1.10.9",
|
package/src/buildTypes.test.ts
CHANGED
|
@@ -101,6 +101,9 @@ describe("buildTypes", () => {
|
|
|
101
101
|
expect(build).toHaveBeenCalledWith({
|
|
102
102
|
build: {
|
|
103
103
|
emptyOutDir: false,
|
|
104
|
+
sourcemap: true,
|
|
105
|
+
minify: true,
|
|
106
|
+
rollupOptions: undefined,
|
|
104
107
|
lib: {
|
|
105
108
|
entry: "resolvedPath",
|
|
106
109
|
fileName: "embeddable-types",
|
|
@@ -134,6 +137,49 @@ import '../relativePath';`,
|
|
|
134
137
|
expect(getContentHash).not.toHaveBeenCalled();
|
|
135
138
|
expect(fs.rename).not.toHaveBeenCalled();
|
|
136
139
|
});
|
|
140
|
+
|
|
141
|
+
it("should use dev optimizations when watch mode is enabled", async () => {
|
|
142
|
+
await buildTypes({
|
|
143
|
+
...config,
|
|
144
|
+
dev: { watch: true, logger: undefined, sys: undefined },
|
|
145
|
+
} as unknown as ResolvedEmbeddableConfig);
|
|
146
|
+
|
|
147
|
+
expect(build).toHaveBeenCalledWith({
|
|
148
|
+
build: {
|
|
149
|
+
emptyOutDir: false,
|
|
150
|
+
sourcemap: false,
|
|
151
|
+
minify: false,
|
|
152
|
+
rollupOptions: { treeshake: false },
|
|
153
|
+
lib: {
|
|
154
|
+
entry: "resolvedPath",
|
|
155
|
+
fileName: "embeddable-types",
|
|
156
|
+
formats: ["es"],
|
|
157
|
+
},
|
|
158
|
+
outDir: "build",
|
|
159
|
+
},
|
|
160
|
+
logLevel: "error",
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("should rename the built file with hash when not in watch mode", async () => {
|
|
165
|
+
// Reset the mock to control it better
|
|
166
|
+
vi.mocked(path.resolve).mockReset();
|
|
167
|
+
|
|
168
|
+
// Mock the calls in order they happen
|
|
169
|
+
vi.mocked(path.resolve)
|
|
170
|
+
.mockReturnValueOnce("resolvedPath") // typesFilePath in build()
|
|
171
|
+
.mockReturnValueOnce("resolvedPath") // typesFilePath for readFile
|
|
172
|
+
.mockReturnValueOnce("build/embeddable-types.js") // source file for rename
|
|
173
|
+
.mockReturnValueOnce("build/embeddable-types-somehash.js"); // target file for rename
|
|
174
|
+
|
|
175
|
+
await buildTypes(config as unknown as ResolvedEmbeddableConfig);
|
|
176
|
+
|
|
177
|
+
expect(fs.rename).toHaveBeenCalledWith(
|
|
178
|
+
"build/embeddable-types.js",
|
|
179
|
+
"build/embeddable-types-somehash.js"
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
137
183
|
it("should import types from installed libraries if present", async () => {
|
|
138
184
|
const configWithLibrary = {
|
|
139
185
|
...config,
|
package/src/buildTypes.ts
CHANGED
|
@@ -66,6 +66,9 @@ async function build(ctx: ResolvedEmbeddableConfig) {
|
|
|
66
66
|
logLevel: "error",
|
|
67
67
|
build: {
|
|
68
68
|
emptyOutDir: false,
|
|
69
|
+
sourcemap: ctx.dev?.watch ? (false as const) : true, // No sourcemaps for types in dev
|
|
70
|
+
minify: !ctx.dev?.watch, // No minification in dev
|
|
71
|
+
rollupOptions: ctx.dev?.watch ? { treeshake: false } : undefined,
|
|
69
72
|
lib: {
|
|
70
73
|
entry: typesFilePath,
|
|
71
74
|
formats: ["es"],
|
package/src/defineConfig.test.ts
CHANGED
|
@@ -35,7 +35,7 @@ describe("defineConfig", () => {
|
|
|
35
35
|
vi.mocked(path.resolve).mockReturnValue(coreRoot);
|
|
36
36
|
|
|
37
37
|
vi.spyOn(process, "cwd").mockReturnValue(
|
|
38
|
-
"/embeddable-sdk/packages/core-sdk"
|
|
38
|
+
"/embeddable-sdk/packages/core-sdk",
|
|
39
39
|
);
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -94,17 +94,17 @@ describe("defineConfig", () => {
|
|
|
94
94
|
|
|
95
95
|
it("throws error for invalid property", () => {
|
|
96
96
|
expect(() =>
|
|
97
|
-
defineConfig({ plugins: [], invalidProp: "INVALID" as any } as any)
|
|
97
|
+
defineConfig({ plugins: [], invalidProp: "INVALID" as any } as any),
|
|
98
98
|
).toThrow(
|
|
99
|
-
`Invalid Embeddable Configuration: "": Unrecognized key(s) in object: 'invalidProp'}
|
|
99
|
+
`Invalid Embeddable Configuration: "": Unrecognized key(s) in object: 'invalidProp'}`,
|
|
100
100
|
);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it("throws error for invalid property value", () => {
|
|
104
104
|
expect(() =>
|
|
105
|
-
defineConfig({ plugins: [], pushBaseUrl: 123 as any } as any)
|
|
105
|
+
defineConfig({ plugins: [], pushBaseUrl: 123 as any } as any),
|
|
106
106
|
).toThrow(
|
|
107
|
-
`Invalid Embeddable Configuration: "pushBaseUrl": Expected string, received number}
|
|
107
|
+
`Invalid Embeddable Configuration: "pushBaseUrl": Expected string, received number}`,
|
|
108
108
|
);
|
|
109
109
|
});
|
|
110
110
|
|
|
@@ -157,9 +157,9 @@ describe("defineConfig", () => {
|
|
|
157
157
|
|
|
158
158
|
it("throws error for invalid region", () => {
|
|
159
159
|
expect(() =>
|
|
160
|
-
defineConfig({ plugins: [], region: "INVALID" as any })
|
|
160
|
+
defineConfig({ plugins: [], region: "INVALID" as any }),
|
|
161
161
|
).toThrow(
|
|
162
|
-
`Invalid Embeddable Configuration: "region": Invalid literal value, expected "legacy-US"}
|
|
162
|
+
`Invalid Embeddable Configuration: "region": Invalid literal value, expected "legacy-US"}`,
|
|
163
163
|
);
|
|
164
164
|
});
|
|
165
165
|
});
|