Skip to content
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

Building elements in a single config #56

Merged
merged 8 commits into from
May 13, 2019

Conversation

rorticus
Copy link
Contributor

@rorticus rorticus commented May 6, 2019

Instead of passing a single webpack configuration for each element being built, this is passing a single webpack configuration for all elements. Previously, it would crash if you turned off onlyCompileBundledFiles in ts-loader and ran it on @dojo/widgets because it would run out of memory. In theory this was because each configuration would be loading all the dependencies together and there would be no sharing between them. Remember webpack, sharing is caring!

When running this locally, it'd produce the following structure for @dojo/widgets,

output/
    accordian-pane/
        accordian-pane-1.0.0.js
        accordian-pane-1.0.0.css
    button/
    rinse, lather, repeat for all widgets
    blahblah.svg
    blahblah2.ttf
  • Compared to the current version of cli-build-webpack, it's missing the dist directory under output/. This shouldn't be difficult to include.
  • I was having trouble getting file-loader to copy those svg/ttf assets into each widgets directory instead of just leaving them at the root.

I tested that the widgets were being created correctly by quickly creating an example page for the button widget and pulling in the dependencies. Things seemed like they were working fine, but a better test might be to generate everything and then copy the resulting files into the custom element showcase.

@rorticus rorticus requested review from agubler and matt-gadd May 6, 2019 19:11
@@ -115,8 +116,8 @@ export default function webpackConfigFactory(args: any): webpack.Configuration {
}, {}),
node: { dgram: 'empty', net: 'empty', tls: 'empty', fs: 'empty' },
output: {
chunkFilename: `[name]-${packageJson.version}.js`,
filename: `[name]-${packageJson.version}.js`,
chunkFilename: `[name]/[name]-${packageJson.version}.js`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was having trouble getting file-loader to copy those svg/ttf assets into each widgets directory instead of just leaving them at the root.

To resolve this issue, shall we drop the folder and have all the elements built at the root, relative to the svg/ttf assets...? (ps don't forget to do the same for the css)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if we build everything to the root we don't have an issue. The only problem I can see with that is that you won't have a clear picture of what static assets go with what widgets, since they would no longer be bundled together.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that's fine to be honest - as we won't know what assets are for what widget anyway so would have to blindly copy everything into every folder...

@agubler agubler mentioned this pull request May 9, 2019
@agubler
Copy link
Member

agubler commented May 9, 2019

@rorticus @dojo/webpack-contrib@6.0.0-alpha.1 is released

@rorticus
Copy link
Contributor Author

OK, flattened out the output directory so everything is built right in output/

image

@rorticus rorticus marked this pull request as ready for review May 10, 2019 11:21
@rorticus
Copy link
Contributor Author

Added the dev/dist directories back in.

image

@@ -190,7 +174,12 @@ export default function webpackConfigFactory(args: any): webpack.Configuration {
getUMDCompatLoader({ bundles: args.bundles }),
{
loader: 'ts-loader',
options: { onlyCompileBundledFiles: true, instance: jsonpIdent, transpileOnly: true, compilerOptions }
options: {
onlyCompileBundledFiles: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave this as true until we make the changes for the custom element transformer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

options: {
onlyCompileBundledFiles: false,
instance: jsonpIdent,
transpileOnly: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just remove this flag (it defaults to true).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

package.json Outdated
@@ -77,6 +77,7 @@
"cpx": "~1.5.0",
"cypress": "3.1.3",
"execa": "0.8.0",
"http-server": "^0.11.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pin this dep please?

@@ -223,11 +223,11 @@ const command: Command = {
});
let configs: webpack.Configuration[];
if (args.mode === 'dev') {
configs = elements.map((element: any) => devConfigFactory({ ...rc, ...commandLineArgs, element }));
configs = [devConfigFactory({ ...rc, ...commandLineArgs, elements })];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pass an array of configs any more?

@rorticus
Copy link
Contributor Author

OK, refactored to not pass an array of configs anymore.

@codecov
Copy link

codecov bot commented May 11, 2019

Codecov Report

Merging #56 into master will increase coverage by 1.39%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #56      +/-   ##
=========================================
+ Coverage   69.91%   71.3%   +1.39%     
=========================================
  Files           8       8              
  Lines         359     352       -7     
  Branches       62      59       -3     
=========================================
  Hits          251     251              
+ Misses        108     101       -7
Impacted Files Coverage Δ
src/base.config.ts 34.92% <ø> (+3.49%) ⬆️
src/dist.config.ts 44.44% <0%> (ø) ⬆️
src/dev.config.ts 30.76% <0%> (ø) ⬆️
src/main.ts 95.23% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 150dc16...e7f787f. Read the comment docs.

const outputPath = output!.path as string;

config.plugins = [...plugins!, new CleanWebpackPlugin([location], { root: outputPath, verbose: false })];
config.plugins = [...plugins!, new CleanWebpackPlugin([outputPath], { root: outputPath, verbose: false })];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry just noticed this, we only want to clean the target for the mode that is being built. For example in this case, path.join(outputPath, 'dev')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants