build: add esm format

This commit is contained in:
haiqin 2024-01-08 11:49:49 +08:00
parent 95f658a6e5
commit b4bbd146e8
6 changed files with 27 additions and 20 deletions

3
.gitignore vendored
View File

@ -5,3 +5,6 @@ package-lock.json
pnpm-lock.yaml
/packages/**/node_modules
/packages/inula-cli/lib
build
/packages/inula-router/connectRouter
/packages/inula-router/router

View File

@ -18,14 +18,7 @@ module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: ['> 1%', 'last 2 versions', 'not ie <= 8'],
node: 'current',
},
useBuiltIns: 'usage',
corejs: 3,
},
{ targets: { node: 'current' } },
],
[
'@babel/preset-typescript',

View File

@ -38,6 +38,10 @@ export default {
name: 'InulaI18n',
format: 'umd',
},
{
file: path.resolve(output, 'intl.esm-browser.js'),
format: 'esm',
}
],
plugins: [
nodeResolve({

View File

@ -17,14 +17,7 @@ module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
'browsers' : ['> 1%', 'last 2 versions', 'not ie <= 8'],
'node': 'current'
},
useBuiltIns: 'usage',
corejs: 3,
}
{ targets: { node: 'current' }},
],
[
'@babel/preset-typescript',

View File

@ -21,13 +21,16 @@ import { babel } from '@rollup/plugin-babel';
export default {
input: './index.ts',
output: {
output: [{
file: 'dist/inulaRequest.js',
format: 'umd',
exports: 'named',
name: 'inulaRequest',
sourcemap: false,
},
}, {
file: 'dist/inulaRequest.esm-browser.js',
format: 'esm',
}],
plugins: [
resolve(),
commonjs(),
@ -41,4 +44,7 @@ export default {
presets: ['@babel/preset-env']
})
],
external:[
'openinula'
]
};

View File

@ -86,6 +86,11 @@ function genConfig(mode) {
name: 'Inula',
format: 'umd',
},
{
file: outputResolve('esm', getOutputName(mode)),
sourcemap,
format: 'esm',
},
],
plugins: [
...getBasicPlugins(mode),
@ -104,10 +109,13 @@ function genConfig(mode) {
function genJSXRuntimeConfig(mode) {
return {
input: path.resolve(libDir, 'src', 'jsx-runtime.ts'),
output: {
output: [{
file: outputResolve('jsx-runtime.js'),
format: 'cjs',
},
}, {
file: outputResolve('jsx-runtime.esm-browser.js'),
format: 'esm',
}],
plugins: [...getBasicPlugins(mode)],
};
}