-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
src/base.config.ts
Outdated
@@ -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`, |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
@rorticus |
src/base.config.ts
Outdated
@@ -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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
src/base.config.ts
Outdated
options: { | ||
onlyCompileBundledFiles: false, | ||
instance: jsonpIdent, | ||
transpileOnly: false, |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 })]; |
There was a problem hiding this comment.
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?
OK, refactored to not pass an array of configs anymore. |
95d0750
to
af1ed14
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
src/dev.config.ts
Outdated
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 })]; |
There was a problem hiding this comment.
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')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
ints-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,
dist
directory underoutput/
. This shouldn't be difficult to include.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.