-
Notifications
You must be signed in to change notification settings - Fork 28
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
Webpack bundling changes #453
Conversation
I need to continue testing and make sure I didn't break anything |
TODO edit README? |
web/webpack.config.js
Outdated
assetModuleFilename: 'assets/[hash][ext][query]', | ||
}, | ||
externals: { | ||
// Schemas lib external to this webpack build. Imported in html file. |
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.
More explicit: import has to be in HTML
Add ref to webpack docs
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.
Does it have to be in the header?
export const getSchema = async (schema) => { | ||
return (await import(`./templates/${schema}/schema.json`)).default; | ||
}; | ||
export const getExportFormats = async (schema) => { |
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.
getLocale?
I think the only change NML folks will need to worry about for their bundling logic is that |
Looks great, I'm merging into master! And then Ken can merge into DH2-i18n-rc1 on his schedule. The Wastewater update will also have to be merged into master and into DH2-i18n-rc1, but I can do this as soon as Charlie ok's it. |
yarn build:web
takes a while, and rebuilding the entire application isn't necessary if users are only editing schemas (as bundling the schemas takes much less time than bundling everything else).I introduce
yarn build:schemas
, which only updates the schema content and is pretty quick.How does this work?:
menu
,getSchema
, andgetExportFormats
are moved toschemas.js
index.js
imports these asimport ... from 'schemas'
webpack.config.js
thatschemas
is an external libraryschemas.js
webpack.schemas.js
file bundlesschemas.js
instead, and outputs a locally available libraryschemas
library insideindex.html
, which allows the originalwebpack.config.js
build to reference this externalschemas
library without actually bundling itSince the functions inside
schemas.js
are the only JavaScript that actually imports schema stuff (specificallyschema.json
andexport.js files
), any edits to schema stuff will not affect thewebpack.config.js
build. So if a user edits the schema content, they do not have to re-run the lengthywebpack.config.js
build. Re-runningwebpack.schemas.js
will suffice.