Skip to content

Commit

Permalink
Pass features map down to BTR
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman committed May 12, 2021
1 parent a1feee0 commit 319c013
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ npm-debug.log
yarn.lock
/test-app/package-lock.json
/test-app/.dojorc
.vscode/
4 changes: 2 additions & 2 deletions src/base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class InsertScriptPlugin {
}
}

export default function webpackConfigFactory(args: any): webpack.Configuration {
export default function webpackConfigFactory(args: any): { config: webpack.Configuration; features: any } {
tsnode.register({ transpileOnly: true });
const isLegacy = args.legacy;
const experimental = args.experimental || {};
Expand Down Expand Up @@ -676,5 +676,5 @@ export default function webpackConfigFactory(args: any): webpack.Configuration {
}
};

return config as webpack.Configuration;
return { config, features };
}
2 changes: 1 addition & 1 deletion src/base.test.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ExternalLoaderPlugin from '@dojo/webpack-contrib/external-loader-plugin/E
const WrapperPlugin = require('wrapper-webpack-plugin');

function webpackConfig(args: any): webpack.Configuration {
const config = baseConfigFactory(args);
const { config } = baseConfigFactory(args);
const { plugins, module } = config;
const externals: any[] = (config.externals as any[]) || [];

Expand Down
5 changes: 3 additions & 2 deletions src/dev.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function webpackConfig(args: any): webpack.Configuration {
const base = args.target === 'electron' ? './' : args.base || '/';

const basePath = process.cwd();
const config = baseConfigFactory(args);
const { config, features } = baseConfigFactory(args);
const manifest: WebAppManifest = args.pwa && args.pwa.manifest;
const { plugins, output, module } = config;
const outputPath = path.join(output!.path!, 'dev');
Expand Down Expand Up @@ -131,7 +131,8 @@ window['${libraryName}'].base = '${base}'</script>`,
baseUrl: base,
scope: libraryName,
onDemand: Boolean(args.serve && args.watch),
cacheOptions: { ...cacheOptions, invalidates: [] }
cacheOptions: { ...cacheOptions, invalidates: [] },
features
})
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/dist.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ All rights reserved
function webpackConfig(args: any): webpack.Configuration {
const basePath = process.cwd();
const base = args.target === 'electron' ? './' : args.base || '/';
const config = baseConfigFactory(args);
const { config, features } = baseConfigFactory(args);
const manifest: WebAppManifest = args.pwa && args.pwa.manifest;
const { plugins, output } = config;
const outputPath = path.join(output!.path!, 'dist');
Expand Down Expand Up @@ -156,7 +156,8 @@ function webpackConfig(args: any): webpack.Configuration {
baseUrl: base,
scope: libraryName,
onDemand: Boolean(args.serve && args.watch),
cacheOptions: { ...cacheOptions, invalidates: [] }
cacheOptions: { ...cacheOptions, invalidates: [] },
features
})
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ async function serve(configs: webpack.Configuration[], args: any, esbuild = fals
compiler: (compiler as any).compilers ? (compiler as any).compilers[0] : compiler,
entries: mainConfig.entry ? Object.keys(mainConfig.entry) : [],
outputPath: outputDir,
jsonpName
jsonpName,
features: args['features']
});
app.use(base, (req, res, next) => onDemandBtr.middleware(req, res, next));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('command', () => {

it('can run dev mode', () => {
const main = mockModule.getModuleUnderTest().default;
main.run(getMockHelper(), { mode: 'dev' }).then(() => {
return main.run(getMockHelper(), { mode: 'dev' }).then(() => {
assert.isTrue(mockDevConfig.called);
assert.isTrue(mockLogger.calledWith('stats', ['dev config']));
});
Expand Down

0 comments on commit 319c013

Please sign in to comment.