Skip to content

Commit afc7985

Browse files
author
Simon Holthausen
committed
adjust message, more robust export extraction, tests
1 parent 633e8c2 commit afc7985

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

packages/kit/src/packaging/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,24 @@ export async function make_package(config, cwd = process.cwd()) {
112112
// rely on the "svelte" property. Vite/Rollup/Webpack plugin can all deal with it.
113113
// See https://github.com/sveltejs/kit/issues/1959 for more info and related threads.
114114
if (pkg.exports['.']) {
115-
const svelte_export = typeof pkg.exports['.'] === 'string' ? pkg.exports['.'] : undefined;
115+
const svelte_export =
116+
typeof pkg.exports['.'] === 'string'
117+
? pkg.exports['.']
118+
: pkg.exports['.'].import || pkg.exports['.'].default;
116119
if (svelte_export) {
117120
pkg.svelte = svelte_export;
118121
} else {
119122
console.warn(
120-
'The "." entry in "exports" is not a string. ' +
123+
'Cannot generate a "svelte" entry point because ' +
124+
'the "." entry in "exports" is not a string. ' +
121125
'If you set it by hand, please also set one of the options as a "svelte" entry point'
122126
);
123127
}
124128
} else {
125129
console.warn(
126-
'The "." entry in "exports" is not a string. ' +
127-
'If you set it by hand, please also set one of the options as a "svelte" entry point'
130+
'Cannot generate a "svelte" entry point because ' +
131+
'the "." entry in "exports" is missing. ' +
132+
'Please specify one or set a "svelte" entry point yourself'
128133
);
129134
}
130135
}

packages/kit/src/packaging/test/fixtures/exports-merge/expected/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"./Test": "./Test.svelte",
1717
"./package.json": "./package.json"
1818
},
19-
"type": "module"
19+
"type": "module",
20+
"svelte": "./index.js"
2021
}

packages/kit/src/packaging/test/fixtures/exports-replace/expected/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"import": "./index.js"
99
},
1010
"./package.json": "./package.json"
11-
}
11+
},
12+
"svelte": "./Test.svelte"
1213
}

packages/kit/src/packaging/test/fixtures/exports-replace/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
".": {
88
"import": "./index.js"
99
}
10-
}
10+
},
11+
"svelte": "./Test.svelte"
1112
}

0 commit comments

Comments
 (0)