Skip to content

Commit

Permalink
fix: rollup config fixes (inline related)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 16, 2021
1 parent fc2e1ba commit ae8a3d3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"chalk": "^4.1.0",
"consola": "^2.15.3",
Expand Down
32 changes: 24 additions & 8 deletions src/builder/rollup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writeFile } from 'fs/promises'
import { RollupOptions, OutputOptions, OutputChunk, rollup } from 'rollup'
import commonjs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import alias from '@rollup/plugin-alias'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
Expand Down Expand Up @@ -64,6 +64,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {

return {
context: ctx.rootDir,

input: Object.fromEntries(ctx.entries
.filter(entry => entry.builder === 'rollup')
.map(entry => [entry.name, resolve(ctx.rootDir, entry.input)])
Expand All @@ -76,15 +77,19 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
chunkFileNames: 'chunks/[name].js',
format: 'cjs',
exports: 'auto',
preferConst: true
preferConst: true,
externalLiveBindings: false,
freeze: false
},
{
dir: resolve(ctx.rootDir, ctx.outDir),
entryFileNames: '[name].mjs',
chunkFileNames: 'chunks/[name].mjs',
format: 'esm',
exports: 'auto',
preferConst: true
preferConst: true,
externalLiveBindings: false,
freeze: false
}
],

Expand Down Expand Up @@ -119,15 +124,26 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
preferBuiltins: true
}),

esbuild({
target: 'node12',
loaders: {
'.json': 'json'
{
name: 'json',
transform (json, id) {
if (!id || id[0] === '\0' || !id.endsWith('.json')) { return null }
return {
code: 'module.exports = ' + json,
map: null
}
}
},

esbuild({
target: 'node12'
}),

commonjs({
extensions
extensions,
ignore: [
...ctx.externals
]
})
]
}
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@
magic-string "^0.25.7"
resolve "^1.17.0"

"@rollup/plugin-json@^4.1.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3"
integrity sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==
dependencies:
"@rollup/pluginutils" "^3.0.8"

"@rollup/plugin-node-resolve@^11.2.1":
version "11.2.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz#82aa59397a29cd4e13248b106e6a4a1880362a60"
Expand All @@ -301,7 +308,7 @@
is-module "^1.0.0"
resolve "^1.19.0"

"@rollup/pluginutils@^3.1.0":
"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
Expand Down

0 comments on commit ae8a3d3

Please sign in to comment.