Skip to content

Commit

Permalink
fix: adjust exports of SSR (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
licg9999 committed Jun 26, 2023
1 parent 5ff795d commit e47c959
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"imports": {
"statofu": "/dist/statofu.esm.min.js",
"statofu/ssr": "/dist/statofu/ssr.esm.min.js"
"statofu/ssr": "/dist/statofu-ssr.esm.min.js"
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<body>
<div id="root"></div>
<script src="/dist/statofu.umd.min.js"></script>
<script src="/dist/statofu/ssr.umd.min.js"></script>
<script src="/dist/statofu-ssr.umd.min.js"></script>
<script src="../src/appLogics.js"></script>
<script src="../src/index.browser-plain-script-umd.js"></script>
</body>
Expand Down
3 changes: 3 additions & 0 deletions e2e/fixtures/basic-use-in-different-formats/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const webpackConf = {
},
],
},
resolve: {
extensions: ['.ts', '.cjs', '.mjs', '...'],
},
};

module.exports = webpackConf;
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@
},
"./ssr": {
"types": "./dist/ssr/index.d.ts",
"module": "./dist/statofu/ssr.esm.js",
"default": "./dist/statofu/ssr.cjs.js"
"module": "./dist/statofu-ssr.esm.js",
"default": "./dist/statofu-ssr.cjs.js"
},
"./ssr/esm": {
"types": "./dist/ssr/index.d.ts",
"default": "./dist/statofu/ssr.esm.js"
"default": "./dist/statofu-ssr.esm.js"
},
"./ssr/umd": {
"types": "./dist/ssr/index.d.ts",
"default": "./dist/statofu/ssr.umd.js"
"default": "./dist/statofu-ssr.umd.js"
},
"./ssr/cjs": {
"types": "./dist/ssr/index.d.ts",
"default": "./dist/statofu/ssr.cjs.js"
"default": "./dist/statofu-ssr.cjs.js"
},
"./package.json": "./package.json",
"./src/*": "./src/*.ts",
Expand Down
17 changes: 5 additions & 12 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,9 @@ function evaluateInputName(input) {
function evaluateOutputFilePrefix(input, format) {
const { dir, name } = path.parse(path.relative(inputDir, input));

if (isEmpty(dir)) {
return path.join(
outputDir,
`${name === 'index' ? pkgName : path.join(pkgName, name)}.${format}`
);
} else {
if (name === 'index') {
return path.join(outputDir, pkgName, `${dir}.${format}`);
} else {
return path.join(outputDir, pkgName, dir, `${name}.${format}`);
}
}
const parentInfo = isEmpty(dir) ? pkgName : [pkgName, dir].join('-');

const namePrefix = `${name === 'index' ? parentInfo : [parentInfo, name].join('-')}.${format}`;

return path.join(outputDir, namePrefix);
}
1 change: 1 addition & 0 deletions ssr/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/ssr';
1 change: 1 addition & 0 deletions ssr/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/statofu-ssr.cjs');
9 changes: 8 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@
"target": "es2015"
},
"include": ["."],
"exclude": ["**/node_modules", "**/dist", "**/coverage", "**/fixtures", "verdaccio/storage"]
"exclude": [
"**/node_modules",
"**/dist",
"**/coverage",
"**/fixtures",
"ssr",
"verdaccio/storage"
]
}

0 comments on commit e47c959

Please sign in to comment.