Skip to content

Update Rollup #1310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@
"pixelmatch": "4.0.2",
"postcss": "7.0.7",
"puppeteer": "~1.7.0",
"rollup": "0.68.2",
"rollup": "1.1.0",
"rollup-plugin-commonjs": "9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "3.4.0",
"rollup-plugin-node-resolve": "4.0.0",
"rollup-pluginutils": "2.3.3",
"semver": "5.6.0",
"terser": "3.14.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ if (success) {
format: 'cjs',
file: DEST_FILE

}).then(output => {
}).then(({ output }) => {
try {
let outputText = updateBuildIds(buildId, output.code);
let outputText = updateBuildIds(buildId, output[0].code);

fs.ensureDirSync(path.dirname(DEST_FILE));
fs.writeFileSync(DEST_FILE, outputText);
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-core-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function buildCoreEsm(inputFile, outputFile) {
format: 'es'
});

let code = clientCore.code.trim();
let code = clientCore.output[0].code.trim();
code = dynamicImportFnHack(code);
code = polyfillsHack(code);

Expand Down
2 changes: 1 addition & 1 deletion scripts/build-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (success) {

}).then(clientCore => {

let code = clientCore.code.trim();
let code = clientCore.output[0].code.trim();
code = dynamicImportFnHack(code);

fs.writeFile(outputCoreFile, code, (err) => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-dev-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (success) {

}).then(clientCore => {

let code = clientCore.code.trim();
let code = clientCore.output[0].code.trim();
code = code.replace('exports ', '');

fs.writeFile(outputFile, code, (err) => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = async function buildPolyfills(transpiledPolyfillsDir, outputPol
format: 'es'
});

const transpile = ts.transpileModule(bundleResults.code, {
const transpile = ts.transpileModule(bundleResults.output[0].code, {
compilerOptions: {
target: ts.ScriptTarget.ES5
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-sys-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ function bundleNodeSysMain() {
format: 'cjs',
file: outputPath

}).then(output => {
}).then(({ output }) => {
try {
let outputText = output.code;
let outputText = output[0].code;

const buildId = (process.argv.find(a => a.startsWith('--build-id=')) || '').replace('--build-id=', '');
outputText = outputText.replace(/__BUILDID__/g, buildId);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/app/app-global-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function bundleProjectGlobal(config: Config, compilerCtx: CompilerCtx, bui
buildCtx.global = compilerCtx.moduleFiles[config.globalScript];

// wrap our globals code with our own iife
return await wrapGlobalJs(config, compilerCtx, buildCtx, sourceTarget, namespace, results.code);
return await wrapGlobalJs(config, compilerCtx, buildCtx, sourceTarget, namespace, results.output[0].code);

} catch (e) {
loadRollupDiagnostics(config, compilerCtx, buildCtx, e);
Expand Down
5 changes: 2 additions & 3 deletions src/compiler/bundle/rollup-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createOnWarnFn, loadRollupDiagnostics } from '../../util/logger/logger-
import { getUserCompilerOptions } from '../transpile/compiler-options';
import localResolution from './rollup-plugins/local-resolution';
import inMemoryFsRead from './rollup-plugins/in-memory-fs-read';
import { RollupBuild, RollupDirOptions } from 'rollup'; // types only
import { RollupBuild, RollupOptions } from 'rollup'; // types only
import pathsResolution from './rollup-plugins/paths-resolution';
import pluginHelper from './rollup-plugins/plugin-helper';
import rollupPluginReplace from './rollup-plugins/rollup-plugin-replace';
Expand Down Expand Up @@ -37,10 +37,9 @@ export async function createBundle(config: d.Config, compilerCtx: d.CompilerCtx,

const tsCompilerOptions = await getUserCompilerOptions(config, compilerCtx, buildCtx);

const rollupConfig: RollupDirOptions = {
const rollupConfig: RollupOptions = {
...config.rollupConfig.inputOptions,
input: entryModules.map(b => b.filePath),
experimentalCodeSplitting: true,
preserveSymlinks: false,
treeshake: !config.devMode,
cache: config.enableCache ? compilerCtx.rollupCache : undefined,
Expand Down
9 changes: 7 additions & 2 deletions src/compiler/bundle/write-bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export async function writeEsmModules(config: d.Config, rollupBundle: RollupBuil
intro: getIntroPlaceholder(),
strict: false,
});
return <any>output as d.JSModuleList;

return output
.map(({ fileName, code }) => ({ [fileName]: { code } }))
.reduce((acc, val) => ({ ...acc, ...val })) as d.JSModuleList;
}


Expand Down Expand Up @@ -64,6 +67,8 @@ export async function writeAmdModules(config: d.Config, rollupBundle: RollupBuil
});


return <any>output as d.JSModuleList;
return output
.map(({ fileName, code }) => ({ [fileName]: { code } }))
.reduce((acc, val) => ({ ...acc, ...val })) as d.JSModuleList;
}

18 changes: 16 additions & 2 deletions src/declarations/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export interface RollupConfig {

export interface RollupInputOptions {
context?: string;
moduleContext?: string | ((id: string) => string) | { [id: string]: string };
moduleContext?: ((id: string) => string) | { [id: string]: string };
}

export interface RollupOutputOptions {
Expand All @@ -186,8 +186,22 @@ export interface NodeResolveConfig {
jail?: string;
only?: Array<string | RegExp>;
modulesOnly?: boolean;

/**
* @see https://github.com/browserify/resolve#resolveid-opts-cb
*/
customResolveOptions?: {
[key: string]: string | string[]
basedir?: string;
package?: string;
extensions?: string[];
readFile?: Function;
isFile?: Function;
isDirectory?: Function;
packageFilter?: Function;
pathFilter?: Function;
paths?: Function | string[];
moduleDirectory?: string | string[];
preserveSymlinks?: boolean;
};
}

Expand Down
5 changes: 5 additions & 0 deletions src/testing/testing-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ export class TestingConfig implements d.Config {
minifyJs: boolean;
testing: d.TestingConfig;
validateTypes = false;
nodeResolve: d.NodeResolveConfig = {
customResolveOptions: {
preserveSymlinks: true,
},
};
}