Skip to content

Commit b92cf52

Browse files
authored
Add exports field in package.json for UI libraries (#6715)
1 parent feccc94 commit b92cf52

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

packages/survey-creator-js/webpack.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ const buildPlatformJson = {
5454
"@types/react-dom": "*",
5555
"@types/react": "*",
5656
},
57+
exports: {
58+
".": {
59+
"types": "./typings/survey-creator-js/entries/index.d.ts",
60+
"import": "./fesm/survey-creator-js.js",
61+
"require": "./survey-creator-js.js"
62+
}
63+
},
5764
peerDependenciesMeta: {
5865
"ace-builds": {
5966
"optional": true

packages/survey-creator-react/webpack.config.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ const buildPlatformJson = {
4646
node: ">=0.10.0"
4747
},
4848
typings: "./typings/entries/index.d.ts",
49+
exports: {
50+
".": {
51+
"types": "./typings/entries/index.d.ts",
52+
"import": "./fesm/survey-creator-react.js",
53+
"require": "./survey-creator-react.js"
54+
}
55+
},
4956
peerDependencies: {
5057
"ace-builds": "^1.4.12",
5158
"react": "^16.5.0 || ^17.0.1 || ^18.1.0 || ^19.0.0",
@@ -79,7 +86,6 @@ function getPercentageHandler(emitNonSourceFiles, buildPath) {
7986
};
8087
}
8188

82-
8389
module.exports = function (options) {
8490
const buildPath = __dirname + "/build/";
8591
const isProductionBuild = options.buildType === "prod";
@@ -136,7 +142,7 @@ module.exports = function (options) {
136142
},
137143
{
138144
test: /\.html$/,
139-
exclude: [/node_modules/, require.resolve('./index.html')],
145+
exclude: [/node_modules/, require.resolve("./index.html")],
140146
loader: "html-loader"
141147
},
142148
{
@@ -153,8 +159,8 @@ module.exports = function (options) {
153159
filename: "[name]" + (isProductionBuild ? ".min" : "") + ".js",
154160
library: {
155161
root: options.libraryName || "SurveyCreator",
156-
amd: '[dashedname]',
157-
commonjs: '[dashedname]',
162+
amd: "[dashedname]",
163+
commonjs: "[dashedname]",
158164
},
159165
libraryTarget: "umd",
160166
globalObject: "this",
@@ -222,7 +228,7 @@ module.exports = function (options) {
222228
]);
223229
config.devServer = {
224230
static: {
225-
directory: path.join(__dirname, '.'),
231+
directory: path.join(__dirname, "."),
226232
},
227233
//host: "0.0.0.0",
228234
compress: false,

0 commit comments

Comments
 (0)