Skip to content

Commit

Permalink
feat: use systemjs property in package.json to control build output
Browse files Browse the repository at this point in the history
  • Loading branch information
streamside committed Sep 6, 2022
1 parent 2d2eb31 commit a485d88
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions commands/build/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const config = ({
getExternal = getExternalDefault,
getOutputFile = getOutputFileDefault,
getOutputName = getOutputNameDefault,
// Return false if no build should be done, otherwise true
enabled = () => true,
} = {},
} = {}) => {
const CWD = argv.cwd || cwd;
Expand All @@ -99,7 +101,7 @@ const config = ({
dir = core;
}

if (format === 'esm' && !pkg.module) {
if (!enabled({ pkg })) {
return false;
}
const outputFile = getOutputFile({ pkg, config: argv });
Expand Down Expand Up @@ -203,6 +205,7 @@ const esm = async (argv, core) => {
core,
behaviours: {
getOutputFile: ({ pkg }) => pkg.module,
enabled: ({ pkg }) => !!pkg.module,
},
});
if (!c) {
Expand All @@ -224,13 +227,14 @@ const systemjs = async (argv, core) => {
const { external = [] } = cfg.systemjs || {};
return mergeArray(defaultExternal, external);
},
getOutputFile: ({ config: cfg }) => {
const { outputFile = 'systemjs/index.js' } = cfg.systemjs || {};
return outputFile;
},
getOutputFile: ({ pkg }) => pkg.systemjs,
getOutputName: () => undefined,
enabled: ({ pkg }) => !!pkg.systemjs,
},
});
if (!c) {
return Promise.resolve();
}
const bundle = await rollup.rollup(c.input);
return bundle.write(c.output);
};
Expand Down

0 comments on commit a485d88

Please sign in to comment.