0.5.2 • Published 3 years ago
@shopify/loom-plugin-webpack v0.5.2
@shopify/loom-plugin-webpack
Notes from porting sewing-kit
cacheis set totruein development. Per webpack docs,trueis an alias for{type: 'memory'}, which is the default. So, removed.modeis inferred fromenv. In new sewing-kit, this is explicitly set by each hook that creates a config.targetis computed fromenv. Moved to plugin-webpack for the default configuration creator, removed service-worker as that would be up to the plugin building a service worker, which is out of scope for the core plugin.nodeis set for the server. Added to the default config creator in plugin-webpack.performancegets hints turned off. TODO: move to Shopify or Quilt config, maybe not a good default choice.entriesuses the default paths.sourceRoot, except in some special cases. TODO: move the gem-related and source-map-support special casing to Quilt. Default entry moved to default config creator in plugin-webpack.output.pathuses the default build path. Moved to base config creator, but smartly picks a subdirectory for multi-project workspacesoutput.devtool...sets some debug options based onvscodeDebug. Moved toplugin-vscodeand dependent on a genericdebugflag for the build/ devoutput.publicPathis inferred from lots of workspace stuff. TODO: move to Shopify pluginoutput.filenameis prefixed with the browser target, and computed from production assets.latest/baselineprefixing done byplugin-differential-serving, set the correct filename based onmode === productionin the default config creator.output.globalObjectisselffor browser targets, andglobalotherwise. Done in the default config creator, inferring the correct object from the runtime of a package (and otherwise using the same logic as old SK, but without the dedicated support for service workers).output.chunkFilenameis prefixed with the browser target. This is done through a hook inplugin-differential-serving.output.crossOriginLoadingis set toanonymousin dev. According to this PR, this helps improve stack traces for errors thrown in async chunks. Made part of the default config creator. TODO: check why only in dev.output.hash...gets some good SRI defaults. Added to the default config creator.externalsis set towebpack-node-externalson the server with a handpicked allow list. Gord and I have discussed in the past how this is probably not the right default for node: inlining is likely valuable on the server as the default. There is awebpackExternalshook + plugin creator that can easily accept an array of strings/ regexes for conditional externalizing, which I think is a good tool for things like lambda that may externalize code put into layers.devtoolsis inferred from server/ client/ dev/ prod/ an option on the "style" to use. Recreated the server/client/ dev/ prod behavior, but TODO a decision on package sourcemaps, investigate whether we actually have the right defaults, and see if we want an option on the default webpack config creator to choose fast/ accurate sourcemaps.optimizationgets inferred for production client/ server/ service-worker. Moved most of this logic to the core config creator, gated on production and the target being node/ web. Added hooks for easy access to a few optimization settings, including minimizers. Moved CSS minimizer to plugin-css. TODO need to get the service worker stuff redone eventually, also want to do a once-over to make sure all the default settings make sense for the basic combinations.performanceturns off hints. Replicated in current config but TODO should decide on a better default (mostly looking at the other metaframeworks I guess).plugins.reactServeradds the@shopify/react-serverstuff. TODO createquilt-next’s equivalent (it basically becreateComposedBuildPlugin([webpackCustomEntry((entry) => 'import App from ${JSON.stringify(entry)}; ...')]))plugins.reportadds theBundleAnalyzerReportplugin. TODO move this to Shopify/ shrink-ray plugin, will also need to account for its weird build behavior (I think current sk waits for a log to happen to indicate it finished :horror:)plugins.stylesadds theMiniExtractPluginand avoids some weird CSS warnings. Moved toplugin-css.plugins.typeCheckconditionally includes our plugin to ignore the annoying "missing export" warning for types. Moved toplugin-typescript, referencing an in-package webpack plugin that is like ours but that also handles child compilations. Applied it universally because I did not port the "type check during build" functionality.plugins.watchadds theIgnorePluginfor.d.tsfiles. Moved toplugin-typescript.plugins.manifestsadds our asset manifest plugin. TODO need to figure out where this belongs — is it the right default? Is it aquiltchoice? Is it a Shopify choice?plugins.buildIntegrityincludes our SRI and content hash verification plugins. TODO need to include in the defaults but want them hosted in this repoplugins.outputincludes theNoEmitOnErrorsPlugin. I made the default configoptimization.noEmitOnErrors = trueinstead. TODO see if there is a reason production should output errored assetsplugins.outputlimits the max chunks to 1 for dev server. Moved to default config creator but TODO why only in dev?plugins.outputadds the hash and no-unexpected-tree-shaking plugins for production clients. Added the hash plugin to the default config creator, want to add the no-unexpected-tree-shaking plugin too but TODO want it hosted in the repoplugins.outputadds the compression plugin for Rails. TODO add to a Shopify/ Rails pluginplugins.inputadds the case sensitive file paths plugin. Added to the default Webpack config because it's fine.plugins.defineadds theDefinePlugin, moved to beoptimization.nodeEnv = modeinsteadplugins.lodashdoes some stuff to optimize lodash. TODO put in its own pluginplugins.chunkNamingadds a custom naming strategy. TODO decide whether this is just a better default, or whether should be in the Quilt plugin, or whether we can do some other better magical naming of thingsplugins.graphqladds the persisted GraphQL plugin. TODO move to a dedicated sk pluginplugins.workersadds the@shopify/web-worker’s plugin. Moved toquilt-next’s sk pluginresolve.modulesadds the packages and app directories.packagesis implemented as aliases for the in-repo packages that exist. TODO make the right aliases in place of theapp"root import" as part of quilt's opinions on project structure.resolve.extensionsadds all the supported extensions. Added through plugins using thewebpackExtensionshook.resolve.mainFieldsaddsjsnext:mainto the defaults (defaults). Added to default config, but mademodulepreferred, and TODO determine if we actually want that in the defaultresolve.aliashas the custom alias for service worker stuff, TODO move to a service worker pluginresolve.aliashas a Polaris alias. Implemented as a generic tool throughplugin-package-esnext.resolve.aliashas aliases for Preact. Moved toplugin-reactas an option.resolve.aliashas aliases for polyfills, TODO move to quilt pluginresolveLoaderhas some custom config for E2E and to support nested installs (I think). Not adding.plugins.sasssets up the Sass + CSS + PostCSS config. Logic split between plugin-css and plugin-sass. TODO need to move the shopify config overrides into a Shopify plugin/ the quilt plugin. Also opted not to port the sass resource loader, not sure if it's still needed. Custom plugin needed for configurations using their own postcss plugins to include it in the webpack cache dependencies (postcssPlugins()).pluginsadds lots of JS and TS rules for different environments. Moved everything to use Babel always, and plugin-javascript has a utility to create the Babel rule (uses some hooks added by the babel preset)rules.graphqlincludes graphql-mini-transforms and cache-loader. Moved toplugin-graphql.rulesincludes rules for static files. TODO not implemented yetruleshas tons of checks to create the right Babel config. This is now split between many different plugins usingplugin-babel’s hooks (some need to be moved to Quilt plugin)rules.focusdoes the magic "focus on one section" behavior. TODO need to figure out where this fitsrules.withoutXcover importing file types without the matching dependencies. Not really in the model of new SK, so not implemented.
0.5.2
3 years ago
0.5.1
4 years ago
0.5.0-alpha.2
4 years ago
0.5.0-alpha.1
4 years ago
0.5.0-alpha.0
4 years ago
0.5.0-alpha.4
4 years ago
0.5.0
4 years ago
0.4.0
4 years ago