@teambit/webpack 1.0.107 → 1.0.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/preview/teambit_webpack_webpack-preview.js +1 -0
- package/dist/config/webpack.config.js +1 -2
- package/dist/config/webpack.config.js.map +1 -1
- package/dist/events/webpack-compilation-started-event.d.ts +1 -1
- package/dist/{preview-1703590665075.js → preview-1703698405864.js} +2 -2
- package/dist/transformers/inject-body.d.ts +1 -1
- package/dist/transformers/inject-head.d.ts +1 -1
- package/dist/transformers/transformers.js +2 -4
- package/dist/transformers/transformers.js.map +1 -1
- package/dist/webpack.bundler.js +6 -10
- package/dist/webpack.bundler.js.map +1 -1
- package/dist/webpack.composition.d.ts +2 -2
- package/dist/webpack.main.runtime.d.ts +7 -7
- package/dist/webpack.main.runtime.js +4 -5
- package/dist/webpack.main.runtime.js.map +1 -1
- package/package.json +16 -23
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
@@ -0,0 +1 @@
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.webpack/webpack-preview"]=t():e["teambit.webpack/webpack-preview"]=t()}(self,(()=>(()=>{"use strict";var e={10546:(e,t,o)=>{var r={id:"teambit.webpack/webpack@1.0.109",homepage:"https://bit.cloud/teambit/webpack/webpack",exported:!0};function n(){const e=i(o(87363));return n=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,n.__bit_component=r,i.__bit_component=r;const p=()=>n().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},n().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/brands/logo-webpack.svg"}));p.__bit_component=r,t.Logo=p},87363:e=>{e.exports=React}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{compositions:()=>u,compositions_metadata:()=>b,overview:()=>l});var e={};o.r(e),o.d(e,{default:()=>d});var t=o(10546);o(87363);const n=MdxJsReact,i=TeambitMdxUiMdxScopeContext;var p=["components"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},a.apply(this,arguments)}var c={},s="wrapper";function d(e){var t=e.components,o=function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(e,p);return(0,n.mdx)(s,a({},c,o,{components:t,mdxType:"MDXLayout"}),(0,n.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"}))}d.isMDXComponent=!0;const u=[t],l=[e],b={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),r})()));
|
@@ -71,7 +71,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
71
71
|
/* eslint-disable complexity */
|
72
72
|
|
73
73
|
function configFactory(target, context) {
|
74
|
-
var _target$chunking;
|
75
74
|
let truthyEntries = Array.isArray(target.entries) && target.entries.length ? target.entries.filter(Boolean) : target.entries || {};
|
76
75
|
if (Array.isArray(truthyEntries) && !truthyEntries.length) {
|
77
76
|
truthyEntries = {};
|
@@ -80,7 +79,7 @@ function configFactory(target, context) {
|
|
80
79
|
const htmlConfig = target.html ?? context.html;
|
81
80
|
const compress = target.compress ?? context.compress;
|
82
81
|
const htmlPlugins = htmlConfig ? generateHtmlPlugins(htmlConfig) : undefined;
|
83
|
-
const splitChunks =
|
82
|
+
const splitChunks = target.chunking?.splitChunks;
|
84
83
|
const config = {
|
85
84
|
mode: dev ? 'development' : 'production',
|
86
85
|
// Stop compilation early in production
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_webpack","data","_interopRequireDefault","require","_lodash","_compressionWebpackPlugin","_path","_htmlWebpackPlugin","_webpackAssetsManifest","_webpackFallbacks","_webpackFallbacksProvidePluginConfig","_webpackFallbacksAliases","obj","__esModule","default","configFactory","target","context","
|
1
|
+
{"version":3,"names":["_webpack","data","_interopRequireDefault","require","_lodash","_compressionWebpackPlugin","_path","_htmlWebpackPlugin","_webpackAssetsManifest","_webpackFallbacks","_webpackFallbacksProvidePluginConfig","_webpackFallbacksAliases","obj","__esModule","default","configFactory","target","context","truthyEntries","Array","isArray","entries","length","filter","Boolean","dev","development","htmlConfig","html","compress","htmlPlugins","generateHtmlPlugins","undefined","splitChunks","chunking","config","mode","bail","entry","infrastructureLogging","level","output","path","outputPath","sep","stats","errorDetails","resolve","alias","fallbacksAliases","fallback","fallbacks","plugins","webpack","ProvidePlugin","fallbacksProvidePluginConfig","getAssetManifestPlugin","filename","chunkFilename","runtimeChunkName","optimization","runtimeChunk","name","chunks","concat","CompressionPlugin","WebpackAssetsManifest","entrypoints","configs","map","generateHtmlPlugin","baseConfig","chunksSortMode","chunkOrder","title","templateContent","minify","cache","favicon","filteredConfig","omitBy","isUndefined","HtmlWebpackPlugin"],"sources":["webpack.config.ts"],"sourcesContent":["/* eslint-disable complexity */\nimport webpack, { Configuration } from 'webpack';\nimport { isUndefined, omitBy } from 'lodash';\nimport CompressionPlugin from 'compression-webpack-plugin';\nimport { sep } from 'path';\nimport type { BundlerContext, BundlerHtmlConfig, Target } from '@teambit/bundler';\nimport HtmlWebpackPlugin from 'html-webpack-plugin';\nimport WebpackAssetsManifest from 'webpack-assets-manifest';\nimport { fallbacks } from './webpack-fallbacks';\nimport { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';\nimport { fallbacksAliases } from './webpack-fallbacks-aliases';\n\nexport function configFactory(target: Target, context: BundlerContext): Configuration {\n let truthyEntries =\n Array.isArray(target.entries) && target.entries.length ? target.entries.filter(Boolean) : target.entries || {};\n if (Array.isArray(truthyEntries) && !truthyEntries.length) {\n truthyEntries = {};\n }\n\n const dev = Boolean(context.development);\n const htmlConfig = target.html ?? context.html;\n const compress = target.compress ?? context.compress;\n const htmlPlugins = htmlConfig ? generateHtmlPlugins(htmlConfig) : undefined;\n const splitChunks = target.chunking?.splitChunks;\n\n const config: Configuration = {\n mode: dev ? 'development' : 'production',\n // Stop compilation early in production\n bail: true,\n // These are the \"entry points\" to our application.\n // This means they will be the \"root\" imports that are included in JS bundle.\n // @ts-ignore\n entry: truthyEntries,\n\n infrastructureLogging: {\n level: 'error',\n },\n\n output: {\n // The build folder.\n path: `${target.outputPath}${sep}public`,\n },\n stats: {\n errorDetails: true,\n },\n\n resolve: {\n // TODO - check - we should not need both fallbacks and alias and provider plugin\n alias: fallbacksAliases,\n\n fallback: fallbacks,\n },\n\n plugins: [new webpack.ProvidePlugin(fallbacksProvidePluginConfig), getAssetManifestPlugin()],\n };\n\n if (target.filename) {\n config.output = config.output || {};\n config.output.filename = target.filename;\n }\n\n if (target.chunkFilename) {\n config.output = config.output || {};\n config.output.chunkFilename = target.chunkFilename;\n }\n\n if (target.runtimeChunkName) {\n config.optimization = config.optimization || {};\n config.optimization.runtimeChunk = {\n name: target.runtimeChunkName,\n };\n }\n\n if (splitChunks) {\n config.optimization = config.optimization || {};\n config.optimization.splitChunks = {\n chunks: 'all',\n name: false,\n };\n }\n\n if (htmlPlugins && htmlPlugins.length) {\n if (!config.plugins) {\n config.plugins = [];\n }\n config.plugins = config.plugins.concat(htmlPlugins);\n }\n if (compress) {\n if (!config.plugins) {\n config.plugins = [];\n }\n config.plugins = config.plugins.concat(new CompressionPlugin());\n }\n return config;\n}\n\nfunction getAssetManifestPlugin() {\n return new WebpackAssetsManifest({ entrypoints: true });\n}\n\nfunction generateHtmlPlugins(configs: BundlerHtmlConfig[]) {\n return configs.map((config) => generateHtmlPlugin(config));\n}\n\nfunction generateHtmlPlugin(config: BundlerHtmlConfig) {\n const baseConfig: HtmlWebpackPlugin.Options = {\n filename: config.filename,\n chunks: config.chunks,\n chunksSortMode: config.chunkOrder,\n title: config.title,\n templateContent: config.templateContent,\n minify: config.minify,\n cache: false,\n favicon: config.favicon,\n };\n\n const filteredConfig = omitBy(baseConfig, isUndefined);\n return new HtmlWebpackPlugin(filteredConfig);\n}\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,0BAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,yBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,mBAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,kBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,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EvC,MAAM,CAACuC,KAAK;IACnBC,eAAe,EAAExC,MAAM,CAACwC,eAAe;IACvCC,MAAM,EAAEzC,MAAM,CAACyC,MAAM;IACrBC,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE3C,MAAM,CAAC2C;EAClB,CAAC;EAED,MAAMC,cAAc,GAAG,IAAAC,gBAAM,EAACT,UAAU,EAAEU,qBAAW,CAAC;EACtD,OAAO,KAAIC,4BAAiB,EAACH,cAAc,CAAC;AAC9C"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@1.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@1.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@1.0.109/dist/webpack.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@1.0.109/dist/webpack.docs.mdx';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
@@ -29,8 +29,7 @@ function _getExternals() {
|
|
29
29
|
}
|
30
30
|
function generateAddAliasesFromPeersTransformer(peers, logger) {
|
31
31
|
return (config, context) => {
|
32
|
-
|
33
|
-
const hostRootDir = ((_context$target = context.target) === null || _context$target === void 0 ? void 0 : _context$target.hostRootDir) || context.hostRootDir;
|
32
|
+
const hostRootDir = context.target?.hostRootDir || context.hostRootDir;
|
34
33
|
const peerAliases = peers.reduce((acc, peerName) => {
|
35
34
|
// gets the correct module folder of the package.
|
36
35
|
// this allows us to resolve internal files, for example:
|
@@ -63,8 +62,7 @@ function generateAddAliasesFromPeersTransformer(peers, logger) {
|
|
63
62
|
*/
|
64
63
|
function generateExposePeersTransformer(peers, logger) {
|
65
64
|
return (config, context) => {
|
66
|
-
|
67
|
-
const hostRootDir = ((_context$target2 = context.target) === null || _context$target2 === void 0 ? void 0 : _context$target2.hostRootDir) || context.hostRootDir;
|
65
|
+
const hostRootDir = context.target?.hostRootDir || context.hostRootDir;
|
68
66
|
const exposedRules = (0, _getExposedRules().getExposedRules)(peers, logger, hostRootDir);
|
69
67
|
config.addModuleRules(exposedRules);
|
70
68
|
return config;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_getExposedRules","data","require","_resolvePeer","_getExternals","generateAddAliasesFromPeersTransformer","peers","logger","config","context","
|
1
|
+
{"version":3,"names":["_getExposedRules","data","require","_resolvePeer","_getExternals","generateAddAliasesFromPeersTransformer","peers","logger","config","context","hostRootDir","target","peerAliases","reduce","acc","peerName","resolved","resolvePeerToDirOrFile","addAliases","generateExposePeersTransformer","exposedRules","getExposedRules","addModuleRules","generateExternalsTransformer","depes","externals","getExternals","addExternals"],"sources":["transformers.ts"],"sourcesContent":["import { WebpackConfigTransformContext } from '@teambit/webpack';\nimport { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';\nimport { Logger } from '@teambit/logger';\nimport { getExposedRules } from './get-exposed-rules';\nimport { resolvePeerToDirOrFile } from './resolve-peer';\nimport { getExternals } from './get-externals';\n\nexport function generateAddAliasesFromPeersTransformer(peers: string[], logger: Logger) {\n return (config: WebpackConfigMutator, context: WebpackConfigTransformContext): WebpackConfigMutator => {\n const hostRootDir = context.target?.hostRootDir || context.hostRootDir;\n const peerAliases = peers.reduce((acc, peerName) => {\n // gets the correct module folder of the package.\n // this allows us to resolve internal files, for example:\n // node_modules/react-dom/test-utils\n //\n // we can't use require.resolve() because it resolves to a specific file.\n // for example, if we used \"react-dom\": require.resolve(\"react-dom\"),\n // it would try to resolve \"react-dom/test-utils\" as:\n // node_modules/react-dom/index.js/test-utils\n const resolved = resolvePeerToDirOrFile(peerName, logger, hostRootDir);\n // Sometime there are packages that only hold icons for example, so there is no main property in their package.json\n // so they can't be resolved.\n // in such cases do not add them to the aliases.\n // We already log that cases in the resolvePeerToDirOrFile function.\n if (resolved) {\n acc[peerName] = resolved;\n }\n return acc;\n }, {});\n\n config.addAliases(peerAliases);\n return config;\n };\n}\n\n// [dead code] - no longer used\n/**\n * Generate a transformer that expose all the peers as global via the expose loader\n * @param peers\n * @returns\n */\nexport function generateExposePeersTransformer(peers: string[], logger: Logger) {\n return (config: WebpackConfigMutator, context: WebpackConfigTransformContext): WebpackConfigMutator => {\n const hostRootDir = context.target?.hostRootDir || context.hostRootDir;\n const exposedRules = getExposedRules(peers, logger, hostRootDir);\n config.addModuleRules(exposedRules);\n return config;\n };\n}\n\n/**\n * Generate a transformer that expose all the peers as global via the expose loader\n * @param peers\n * @returns\n */\nexport function generateExternalsTransformer(depes: string[]) {\n return (config: WebpackConfigMutator): WebpackConfigMutator => {\n const externals = getExternals(depes);\n config.addExternals(externals);\n return config;\n };\n}\n"],"mappings":";;;;;;;;AAGA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,SAASI,sCAAsCA,CAACC,KAAe,EAAEC,MAAc,EAAE;EACtF,OAAO,CAACC,MAA4B,EAAEC,OAAsC,KAA2B;IACrG,MAAMC,WAAW,GAAGD,OAAO,CAACE,MAAM,EAAED,WAAW,IAAID,OAAO,CAACC,WAAW;IACtE,MAAME,WAAW,GAAGN,KAAK,CAACO,MAAM,CAAC,CAACC,GAAG,EAAEC,QAAQ,KAAK;MAClD;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,MAAMC,QAAQ,GAAG,IAAAC,qCAAsB,EAACF,QAAQ,EAAER,MAAM,EAAEG,WAAW,CAAC;MACtE;MACA;MACA;MACA;MACA,IAAIM,QAAQ,EAAE;QACZF,GAAG,CAACC,QAAQ,CAAC,GAAGC,QAAQ;MAC1B;MACA,OAAOF,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;IAENN,MAAM,CAACU,UAAU,CAACN,WAAW,CAAC;IAC9B,OAAOJ,MAAM;EACf,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASW,8BAA8BA,CAACb,KAAe,EAAEC,MAAc,EAAE;EAC9E,OAAO,CAACC,MAA4B,EAAEC,OAAsC,KAA2B;IACrG,MAAMC,WAAW,GAAGD,OAAO,CAACE,MAAM,EAAED,WAAW,IAAID,OAAO,CAACC,WAAW;IACtE,MAAMU,YAAY,GAAG,IAAAC,kCAAe,EAACf,KAAK,EAAEC,MAAM,EAAEG,WAAW,CAAC;IAChEF,MAAM,CAACc,cAAc,CAACF,YAAY,CAAC;IACnC,OAAOZ,MAAM;EACf,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASe,4BAA4BA,CAACC,KAAe,EAAE;EAC5D,OAAQhB,MAA4B,IAA2B;IAC7D,MAAMiB,SAAS,GAAG,IAAAC,4BAAY,EAACF,KAAK,CAAC;IACrChB,MAAM,CAACmB,YAAY,CAACF,SAAS,CAAC;IAC9B,OAAOjB,MAAM;EACf,CAAC;AACH"}
|
package/dist/webpack.bundler.js
CHANGED
@@ -50,11 +50,10 @@ class WebpackBundler {
|
|
50
50
|
this.metaData = metaData;
|
51
51
|
}
|
52
52
|
async run() {
|
53
|
-
var _this$metaData, _this$metaData2;
|
54
53
|
const startTime = Date.now();
|
55
54
|
const compilers = this.configs.map(config => this.webpack(config));
|
56
|
-
const initiator =
|
57
|
-
const envId =
|
55
|
+
const initiator = this.metaData?.initiator;
|
56
|
+
const envId = this.metaData?.envId;
|
58
57
|
const initiatorMessage = initiator ? `process initiated by: ${initiator}.` : '';
|
59
58
|
const envIdMessage = envId ? `config created by env: ${envId}.` : '';
|
60
59
|
const longProcessLogger = this.logger.createLongProcessLogger('running Webpack bundler', compilers.length);
|
@@ -137,21 +136,18 @@ class WebpackBundler {
|
|
137
136
|
const entriesMap = stats.entrypoints;
|
138
137
|
if (!entriesMap || !Object.keys(assetsMap).length) return {};
|
139
138
|
Object.entries(entriesMap).forEach(([, entryVal]) => {
|
140
|
-
var _entryVal$assets, _entryVal$auxiliaryAs;
|
141
139
|
let compressedAssetsSize = 0;
|
142
140
|
let compressedAuxiliaryAssetsSize = 0;
|
143
|
-
|
144
|
-
|
145
|
-
const compressedSize = (_assetsMap$asset$name = assetsMap[asset.name]) === null || _assetsMap$asset$name === void 0 ? void 0 : _assetsMap$asset$name.compressedSize;
|
141
|
+
entryVal.assets?.forEach(asset => {
|
142
|
+
const compressedSize = assetsMap[asset.name]?.compressedSize;
|
146
143
|
if (compressedSize) {
|
147
144
|
// @ts-ignore
|
148
145
|
asset.compressedSize = compressedSize;
|
149
146
|
compressedAssetsSize += compressedSize;
|
150
147
|
}
|
151
148
|
});
|
152
|
-
|
153
|
-
|
154
|
-
const compressedSize = (_assetsMap$asset$name2 = assetsMap[asset.name]) === null || _assetsMap$asset$name2 === void 0 ? void 0 : _assetsMap$asset$name2.compressedSize;
|
149
|
+
entryVal.auxiliaryAssets?.forEach(asset => {
|
150
|
+
const compressedSize = assetsMap[asset.name]?.compressedSize;
|
155
151
|
if (compressedSize) {
|
156
152
|
// @ts-ignore
|
157
153
|
asset.compressedSize = compressedSize;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","_lodash","_pMapSeries","_interopRequireDefault","_path","obj","__esModule","default","WebpackBundler","constructor","targets","configs","logger","webpack","metaData","run","_this$metaData","_this$metaData2","startTime","Date","now","compilers","map","config","initiator","envId","initiatorMessage","envIdMessage","longProcessLogger","createLongProcessLogger","length","componentOutput","mapSeries","compiler","components","getComponents","outputPath","componentsLengthMessage","fullMessage","ids","component","id","toString","join","logProgress","debug","Promise","resolve","err","stats","error","errors","stack","BitError","info","toJson","all","entrypoints","warnings","assets","chunkGroupAuxiliary","relatedAssets","cachedAssets","assetsMap","getAssets","entriesAssetsMap","getEntriesAssetsMap","Object","values","assetsByChunkName","getErrors","compilation","outputOptions","path","endTime","end","fieldsToShow","webpackError","lines","fieldName","undefined","errorMessage","compact","reduce","acc","asset","name","size","compressedSize","getCompressedSize","entriesMap","keys","entries","forEach","entryVal","_entryVal$assets","_entryVal$auxiliaryAs","compressedAssetsSize","compressedAuxiliaryAssetsSize","_assetsMap$asset$name","auxiliaryAssets","_assetsMap$asset$name2","related","isEmpty","gzipped","find","relatedAsset","type","substring","lastIndexOf","sep","target","targetCandidate","Error","exports"],"sources":["webpack.bundler.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport type { Bundler, BundlerResult, Asset, Target, EntriesAssetsMap, BundlerContextMetaData } from '@teambit/bundler';\nimport type { Logger } from '@teambit/logger';\nimport { compact, isEmpty } from 'lodash';\nimport mapSeries from 'p-map-series';\nimport type { Compiler, Configuration, StatsCompilation, StatsAsset } from 'webpack';\nimport { sep } from 'path';\n\ntype AssetsMap = { [assetId: string]: Asset };\nexport class WebpackBundler implements Bundler {\n constructor(\n /**\n * targets to bundle.\n */\n private targets: Target[],\n\n /**\n * webpack configuration.\n */\n private configs: Configuration[],\n\n private logger: Logger,\n\n private webpack,\n\n private metaData?: BundlerContextMetaData | undefined\n ) {}\n\n async run(): Promise<BundlerResult[]> {\n const startTime = Date.now();\n const compilers = this.configs.map((config: any) => this.webpack(config));\n const initiator = this.metaData?.initiator;\n const envId = this.metaData?.envId;\n const initiatorMessage = initiator ? `process initiated by: ${initiator}.` : '';\n const envIdMessage = envId ? `config created by env: ${envId}.` : '';\n\n const longProcessLogger = this.logger.createLongProcessLogger('running Webpack bundler', compilers.length);\n const componentOutput = await mapSeries(compilers, (compiler: Compiler) => {\n const components = this.getComponents(compiler.outputPath);\n const componentsLengthMessage = `running on ${components.length} components`;\n const fullMessage = `${initiatorMessage} ${envIdMessage} ${componentsLengthMessage}`;\n const ids = components.map((component) => component.id.toString()).join(', ');\n longProcessLogger.logProgress(`${fullMessage}`);\n this.logger.debug(`${fullMessage}\\ncomponents ids: ${ids}`);\n return new Promise((resolve) => {\n // TODO: split to multiple processes to reduce time and configure concurrent builds.\n // @see https://github.com/trivago/parallel-webpack\n return compiler.run((err, stats) => {\n if (err) {\n this.logger.error('get error from webpack compiler, full error:', err);\n\n return resolve({\n errors: [`${err.toString()}\\n${err.stack}`],\n components,\n });\n }\n if (!stats) throw new BitError('unknown build error');\n // const info = stats.toJson();\n\n const info = stats.toJson({\n all: false,\n entrypoints: true,\n warnings: true,\n errors: true,\n assets: true,\n chunkGroupAuxiliary: true,\n relatedAssets: true,\n cachedAssets: true,\n });\n const assetsMap = this.getAssets(info);\n const entriesAssetsMap = this.getEntriesAssetsMap(info, assetsMap);\n\n return resolve({\n assets: Object.values(assetsMap),\n assetsByChunkName: info.assetsByChunkName,\n entriesAssetsMap,\n errors: this.getErrors(info),\n outputPath: stats.compilation.outputOptions.path,\n components,\n warnings: info.warnings,\n startTime,\n endTime: Date.now(),\n });\n });\n });\n });\n longProcessLogger.end();\n return componentOutput as BundlerResult[];\n }\n\n private getErrors(stats: StatsCompilation): Error[] {\n if (!stats.errors) return [];\n const fieldsToShow = ['message', 'moduleId', 'moduleName', 'moduleIdentifier', 'loc'];\n return stats.errors.map((webpackError) => {\n const lines = fieldsToShow.map((fieldName) => {\n if (webpackError[fieldName]) {\n return `${fieldName}: ${webpackError[fieldName]}`;\n }\n return undefined;\n });\n const errorMessage = compact(lines).join('\\n');\n return new BitError(errorMessage);\n });\n }\n\n private getAssets(stats: StatsCompilation): AssetsMap {\n if (!stats.assets) return {};\n return stats.assets.reduce((acc, asset) => {\n acc[asset.name] = {\n name: asset.name,\n size: asset.size,\n compressedSize: this.getCompressedSize(asset),\n };\n return acc;\n }, {});\n }\n\n private getEntriesAssetsMap(stats: StatsCompilation, assetsMap: AssetsMap): EntriesAssetsMap {\n const entriesMap = stats.entrypoints;\n if (!entriesMap || !Object.keys(assetsMap).length) return {};\n Object.entries(entriesMap).forEach(([, entryVal]) => {\n let compressedAssetsSize = 0;\n let compressedAuxiliaryAssetsSize = 0;\n entryVal.assets?.forEach((asset) => {\n const compressedSize = assetsMap[asset.name]?.compressedSize;\n if (compressedSize) {\n // @ts-ignore\n asset.compressedSize = compressedSize;\n compressedAssetsSize += compressedSize;\n }\n });\n entryVal.auxiliaryAssets?.forEach((asset) => {\n const compressedSize = assetsMap[asset.name]?.compressedSize;\n if (compressedSize) {\n // @ts-ignore\n asset.compressedSize = compressedSize;\n compressedAuxiliaryAssetsSize += compressedSize;\n }\n });\n entryVal.compressedAssetsSize = compressedAssetsSize;\n entryVal.compressedAuxiliaryAssetsSize = compressedAuxiliaryAssetsSize;\n });\n return entriesMap as any as EntriesAssetsMap;\n }\n\n private getCompressedSize(asset: StatsAsset): number | undefined {\n if (!asset.related || isEmpty(asset.related)) return undefined;\n const gzipped = asset.related.find((relatedAsset) => {\n return relatedAsset.type === 'gzipped';\n });\n if (!gzipped) return undefined;\n return gzipped.size;\n }\n\n private getComponents(outputPath: string) {\n const path = outputPath.substring(0, outputPath.lastIndexOf(sep));\n const target = this.targets.find((targetCandidate) => path === targetCandidate.outputPath);\n\n if (!target) throw new Error(`Could not find component id for path \"${path}\"`);\n return target.components;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,QAAA;EAAA,MAAAF,IAAA,G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AE,OAAOxB,SAAS;IAC9B,OAAOwB,OAAO,CAACjB,IAAI;EACrB;EAEQpD,aAAaA,CAACC,UAAkB,EAAE;IACxC,MAAMqC,IAAI,GAAGrC,UAAU,CAACwE,SAAS,CAAC,CAAC,EAAExE,UAAU,CAACyE,WAAW,CAACC,WAAG,CAAC,CAAC;IACjE,MAAMC,MAAM,GAAG,IAAI,CAACrG,OAAO,CAAC+F,IAAI,CAAEO,eAAe,IAAKvC,IAAI,KAAKuC,eAAe,CAAC5E,UAAU,CAAC;IAE1F,IAAI,CAAC2E,MAAM,EAAE,MAAM,IAAIE,KAAK,CAAE,yCAAwCxC,IAAK,GAAE,CAAC;IAC9E,OAAOsC,MAAM,CAAC7E,UAAU;EAC1B;AACF;AAACgF,OAAA,CAAA1G,cAAA,GAAAA,cAAA"}
|
1
|
+
{"version":3,"names":["_bitError","data","require","_lodash","_pMapSeries","_interopRequireDefault","_path","obj","__esModule","default","WebpackBundler","constructor","targets","configs","logger","webpack","metaData","run","startTime","Date","now","compilers","map","config","initiator","envId","initiatorMessage","envIdMessage","longProcessLogger","createLongProcessLogger","length","componentOutput","mapSeries","compiler","components","getComponents","outputPath","componentsLengthMessage","fullMessage","ids","component","id","toString","join","logProgress","debug","Promise","resolve","err","stats","error","errors","stack","BitError","info","toJson","all","entrypoints","warnings","assets","chunkGroupAuxiliary","relatedAssets","cachedAssets","assetsMap","getAssets","entriesAssetsMap","getEntriesAssetsMap","Object","values","assetsByChunkName","getErrors","compilation","outputOptions","path","endTime","end","fieldsToShow","webpackError","lines","fieldName","undefined","errorMessage","compact","reduce","acc","asset","name","size","compressedSize","getCompressedSize","entriesMap","keys","entries","forEach","entryVal","compressedAssetsSize","compressedAuxiliaryAssetsSize","auxiliaryAssets","related","isEmpty","gzipped","find","relatedAsset","type","substring","lastIndexOf","sep","target","targetCandidate","Error","exports"],"sources":["webpack.bundler.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport type { Bundler, BundlerResult, Asset, Target, EntriesAssetsMap, BundlerContextMetaData } from '@teambit/bundler';\nimport type { Logger } from '@teambit/logger';\nimport { compact, isEmpty } from 'lodash';\nimport mapSeries from 'p-map-series';\nimport type { Compiler, Configuration, StatsCompilation, StatsAsset } from 'webpack';\nimport { sep } from 'path';\n\ntype AssetsMap = { [assetId: string]: Asset };\nexport class WebpackBundler implements Bundler {\n constructor(\n /**\n * targets to bundle.\n */\n private targets: Target[],\n\n /**\n * webpack configuration.\n */\n private configs: Configuration[],\n\n private logger: Logger,\n\n private webpack,\n\n private metaData?: BundlerContextMetaData | undefined\n ) {}\n\n async run(): Promise<BundlerResult[]> {\n const startTime = Date.now();\n const compilers = this.configs.map((config: any) => this.webpack(config));\n const initiator = this.metaData?.initiator;\n const envId = this.metaData?.envId;\n const initiatorMessage = initiator ? `process initiated by: ${initiator}.` : '';\n const envIdMessage = envId ? `config created by env: ${envId}.` : '';\n\n const longProcessLogger = this.logger.createLongProcessLogger('running Webpack bundler', compilers.length);\n const componentOutput = await mapSeries(compilers, (compiler: Compiler) => {\n const components = this.getComponents(compiler.outputPath);\n const componentsLengthMessage = `running on ${components.length} components`;\n const fullMessage = `${initiatorMessage} ${envIdMessage} ${componentsLengthMessage}`;\n const ids = components.map((component) => component.id.toString()).join(', ');\n longProcessLogger.logProgress(`${fullMessage}`);\n this.logger.debug(`${fullMessage}\\ncomponents ids: ${ids}`);\n return new Promise((resolve) => {\n // TODO: split to multiple processes to reduce time and configure concurrent builds.\n // @see https://github.com/trivago/parallel-webpack\n return compiler.run((err, stats) => {\n if (err) {\n this.logger.error('get error from webpack compiler, full error:', err);\n\n return resolve({\n errors: [`${err.toString()}\\n${err.stack}`],\n components,\n });\n }\n if (!stats) throw new BitError('unknown build error');\n // const info = stats.toJson();\n\n const info = stats.toJson({\n all: false,\n entrypoints: true,\n warnings: true,\n errors: true,\n assets: true,\n chunkGroupAuxiliary: true,\n relatedAssets: true,\n cachedAssets: true,\n });\n const assetsMap = this.getAssets(info);\n const entriesAssetsMap = this.getEntriesAssetsMap(info, assetsMap);\n\n return resolve({\n assets: Object.values(assetsMap),\n assetsByChunkName: info.assetsByChunkName,\n entriesAssetsMap,\n errors: this.getErrors(info),\n outputPath: stats.compilation.outputOptions.path,\n components,\n warnings: info.warnings,\n startTime,\n endTime: Date.now(),\n });\n });\n });\n });\n longProcessLogger.end();\n return componentOutput as BundlerResult[];\n }\n\n private getErrors(stats: StatsCompilation): Error[] {\n if (!stats.errors) return [];\n const fieldsToShow = ['message', 'moduleId', 'moduleName', 'moduleIdentifier', 'loc'];\n return stats.errors.map((webpackError) => {\n const lines = fieldsToShow.map((fieldName) => {\n if (webpackError[fieldName]) {\n return `${fieldName}: ${webpackError[fieldName]}`;\n }\n return undefined;\n });\n const errorMessage = compact(lines).join('\\n');\n return new BitError(errorMessage);\n });\n }\n\n private getAssets(stats: StatsCompilation): AssetsMap {\n if (!stats.assets) return {};\n return stats.assets.reduce((acc, asset) => {\n acc[asset.name] = {\n name: asset.name,\n size: asset.size,\n compressedSize: this.getCompressedSize(asset),\n };\n return acc;\n }, {});\n }\n\n private getEntriesAssetsMap(stats: StatsCompilation, assetsMap: AssetsMap): EntriesAssetsMap {\n const entriesMap = stats.entrypoints;\n if (!entriesMap || !Object.keys(assetsMap).length) return {};\n Object.entries(entriesMap).forEach(([, entryVal]) => {\n let compressedAssetsSize = 0;\n let compressedAuxiliaryAssetsSize = 0;\n entryVal.assets?.forEach((asset) => {\n const compressedSize = assetsMap[asset.name]?.compressedSize;\n if (compressedSize) {\n // @ts-ignore\n asset.compressedSize = compressedSize;\n compressedAssetsSize += compressedSize;\n }\n });\n entryVal.auxiliaryAssets?.forEach((asset) => {\n const compressedSize = assetsMap[asset.name]?.compressedSize;\n if (compressedSize) {\n // @ts-ignore\n asset.compressedSize = compressedSize;\n compressedAuxiliaryAssetsSize += compressedSize;\n }\n });\n entryVal.compressedAssetsSize = compressedAssetsSize;\n entryVal.compressedAuxiliaryAssetsSize = compressedAuxiliaryAssetsSize;\n });\n return entriesMap as any as EntriesAssetsMap;\n }\n\n private getCompressedSize(asset: StatsAsset): number | undefined {\n if (!asset.related || isEmpty(asset.related)) return undefined;\n const gzipped = asset.related.find((relatedAsset) => {\n return relatedAsset.type === 'gzipped';\n });\n if (!gzipped) return undefined;\n return gzipped.size;\n }\n\n private getComponents(outputPath: string) {\n const path = outputPath.substring(0, outputPath.lastIndexOf(sep));\n const target = this.targets.find((targetCandidate) => path === targetCandidate.outputPath);\n\n if (!target) throw new Error(`Could not find component id for path \"${path}\"`);\n return target.components;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2B,SAAAI,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGpB,MAAMG,cAAc,CAAoB;EAC7CC,WAAWA;EACT;AACJ;AACA;EACYC,OAAiB;EAEzB;AACJ;AACA;EACYC,OAAwB,EAExBC,MAAc,EAEdC,OAAO,EAEPC,QAA6C,EACrD;IAAA,KAZQJ,OAAiB,GAAjBA,OAAiB;IAAA,KAKjBC,OAAwB,GAAxBA,OAAwB;IAAA,KAExBC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K,CAACa,OAAO,CAACG,IAAI,CAAEC,YAAY,IAAK;MACnD,OAAOA,YAAY,CAACC,IAAI,KAAK,SAAS;IACxC,CAAC,CAAC;IACF,IAAI,CAACH,OAAO,EAAE,OAAOpB,SAAS;IAC9B,OAAOoB,OAAO,CAACb,IAAI;EACrB;EAEQpD,aAAaA,CAACC,UAAkB,EAAE;IACxC,MAAMqC,IAAI,GAAGrC,UAAU,CAACoE,SAAS,CAAC,CAAC,EAAEpE,UAAU,CAACqE,WAAW,CAACC,WAAG,CAAC,CAAC;IACjE,MAAMC,MAAM,GAAG,IAAI,CAAC/F,OAAO,CAACyF,IAAI,CAAEO,eAAe,IAAKnC,IAAI,KAAKmC,eAAe,CAACxE,UAAU,CAAC;IAE1F,IAAI,CAACuE,MAAM,EAAE,MAAM,IAAIE,KAAK,CAAE,yCAAwCpC,IAAK,GAAE,CAAC;IAC9E,OAAOkC,MAAM,CAACzE,UAAU;EAC1B;AACF;AAAC4E,OAAA,CAAApG,cAAA,GAAAA,cAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
export declare const Logo: () =>
|
1
|
+
/// <reference types="react" />
|
2
|
+
export declare const Logo: () => JSX.Element;
|
@@ -5,11 +5,11 @@ import { Logger, LoggerMain } from '@teambit/logger';
|
|
5
5
|
import { Workspace } from '@teambit/workspace';
|
6
6
|
import { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';
|
7
7
|
import { WebpackBundler } from './webpack.bundler';
|
8
|
-
export
|
8
|
+
export type WebpackConfigTransformContext = GlobalWebpackConfigTransformContext & {
|
9
9
|
target: Target;
|
10
10
|
};
|
11
|
-
export
|
12
|
-
export
|
11
|
+
export type WebpackConfigDevServerTransformContext = GlobalWebpackConfigTransformContext & DevServerContext;
|
12
|
+
export type GlobalWebpackConfigTransformContext = {
|
13
13
|
mode: BundlerMode;
|
14
14
|
/**
|
15
15
|
* Whether the config is for an env template bundling
|
@@ -23,8 +23,8 @@ export declare type GlobalWebpackConfigTransformContext = {
|
|
23
23
|
*/
|
24
24
|
hostRootDir?: string;
|
25
25
|
};
|
26
|
-
export
|
27
|
-
export
|
26
|
+
export type WebpackConfigTransformer = (config: WebpackConfigMutator, context: WebpackConfigTransformContext) => WebpackConfigMutator;
|
27
|
+
export type WebpackConfigDevServerTransformer = (config: WebpackConfigMutator, context: WebpackConfigDevServerTransformContext) => WebpackConfigMutator;
|
28
28
|
export declare class WebpackMain {
|
29
29
|
/**
|
30
30
|
* Pubsub extension.
|
@@ -69,9 +69,9 @@ export declare class WebpackMain {
|
|
69
69
|
private generateTransformers;
|
70
70
|
private getWebpackInstance;
|
71
71
|
private createDevServerConfig;
|
72
|
-
static slots:
|
72
|
+
static slots: any[];
|
73
73
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
74
74
|
static dependencies: import("@teambit/harmony").Aspect[];
|
75
75
|
static provider([pubsub, workspace, bundler, logger]: [PubsubMain, Workspace, BundlerMain, LoggerMain]): Promise<WebpackMain>;
|
76
76
|
}
|
77
|
-
export declare function runTransformersWithContext(config: WebpackConfigMutator, transformers:
|
77
|
+
export declare function runTransformersWithContext(config: WebpackConfigMutator, transformers: Array<WebpackConfigTransformer | WebpackConfigDevServerTransformer>, context: any): WebpackConfigMutator;
|
@@ -151,10 +151,9 @@ class WebpackMain {
|
|
151
151
|
return (0, _webpackMerge().merge)(target, source);
|
152
152
|
}
|
153
153
|
createBundler(context, transformers = [], initialConfigs, webpackModuleOrPath) {
|
154
|
-
var _context$metaData;
|
155
154
|
const transformerContext = {
|
156
155
|
mode: 'prod',
|
157
|
-
isEnvTemplate:
|
156
|
+
isEnvTemplate: context.metaData?.isEnvTemplate
|
158
157
|
};
|
159
158
|
// eslint-disable-next-line max-len
|
160
159
|
const configs = initialConfigs || this.createConfigs(context.targets, _webpack2().configFactory, transformers, transformerContext, context);
|
@@ -175,13 +174,13 @@ class WebpackMain {
|
|
175
174
|
generateTransformers(_bundlerContext, devServerContext, target) {
|
176
175
|
const transformers = [];
|
177
176
|
// TODO: handle dev server
|
178
|
-
const hostDeps =
|
177
|
+
const hostDeps = target?.hostDependencies || devServerContext?.hostDependencies;
|
179
178
|
if (hostDeps) {
|
180
|
-
if (target
|
179
|
+
if (target?.aliasHostDependencies || devServerContext?.aliasHostDependencies) {
|
181
180
|
const peerAliasesTransformer = (0, _transformers().generateAddAliasesFromPeersTransformer)(hostDeps, this.logger);
|
182
181
|
transformers.push(peerAliasesTransformer);
|
183
182
|
}
|
184
|
-
if (target
|
183
|
+
if (target?.externalizeHostDependencies || devServerContext?.externalizeHostDependencies) {
|
185
184
|
const externalsTransformer = (0, _transformers().generateExternalsTransformer)(hostDeps);
|
186
185
|
transformers.push(externalsTransformer);
|
187
186
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_webpack","data","_interopRequireDefault","require","_pubsub","_bundler","_cli","_logger","_workspace","_webpackMerge","_webpackModules","_transformers","_webpackDev","_webpack2","_webpack3","_webpack4","_webpack5","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","WebpackMain","constructor","pubsub","workspace","bundler","logger","createDevServer","context","transformers","webpackModulePath","webpackDevServerModulePath","config","createDevServerConfig","entry","path","id","rootPath","publicPath","getComponentPathsRegExps","title","wdsPath","resolve","configMutator","WebpackConfigMutator","transformerContext","assign","mode","internalTransformers","generateTransformers","undefined","afterMutation","runTransformersWithContext","clone","WebpackDevServer","raw","getWebpackInstance","webpack","mergeConfig","target","source","merge","createBundler","initialConfigs","webpackModuleOrPath","_context$metaData","isEnvTemplate","metaData","configs","createConfigs","targets","baseConfigFactory","WebpackBundler","factory","bundlerContext","map","baseConfig","_bundlerContext","devServerContext","hostDeps","hostDependencies","aliasHostDependencies","peerAliasesTransformer","generateAddAliasesFromPeersTransformer","push","externalizeHostDependencies","externalsTransformer","generateExternalsTransformer","webpackOrPath","fallback","devServerID","publicRoot","componentPathsRegExps","devServerConfigFactory","provider","logPublisher","createLogger","WebpackAspect","exports","MainRuntime","PubsubAspect","WorkspaceAspect","BundlerAspect","LoggerAspect","addRuntime","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["webpack.main.runtime.ts"],"sourcesContent":["import webpack, { Configuration } from 'webpack';\nimport PubsubAspect, { PubsubMain } from '@teambit/pubsub';\nimport {\n BundlerAspect,\n BundlerContext,\n BundlerMain,\n DevServer,\n DevServerContext,\n BundlerMode,\n Target,\n} from '@teambit/bundler';\nimport { MainRuntime } from '@teambit/cli';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { merge } from 'webpack-merge';\n// We want to import it to make sure bit recognizes it as a dependency\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport WsDevServer from 'webpack-dev-server';\nimport { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';\n\nimport { generateAddAliasesFromPeersTransformer, generateExternalsTransformer } from './transformers';\nimport { configFactory as devServerConfigFactory } from './config/webpack.dev.config';\nimport { configFactory as baseConfigFactory } from './config/webpack.config';\n\nimport { WebpackAspect } from './webpack.aspect';\nimport { WebpackBundler } from './webpack.bundler';\nimport { WebpackDevServer } from './webpack.dev-server';\n\nexport type WebpackConfigTransformContext = GlobalWebpackConfigTransformContext & {\n target: Target;\n};\n\nexport type WebpackConfigDevServerTransformContext = GlobalWebpackConfigTransformContext & DevServerContext;\n\nexport type GlobalWebpackConfigTransformContext = {\n mode: BundlerMode;\n /**\n * Whether the config is for an env template bundling\n */\n isEnvTemplate?: boolean;\n /**\n * A path for the host root dir\n * Host root dir is usually the env root dir\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n hostRootDir?: string;\n};\n\nexport type WebpackConfigTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigTransformContext\n) => WebpackConfigMutator;\n\nexport type WebpackConfigDevServerTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigDevServerTransformContext\n) => WebpackConfigMutator;\n\nexport class WebpackMain {\n constructor(\n /**\n * Pubsub extension.\n */\n public pubsub: PubsubMain,\n\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * bundler extension.\n */\n private bundler: BundlerMain,\n\n /**\n * Logger extension\n */\n public logger: Logger\n ) {}\n\n /**\n * create an instance of bit-compliant webpack dev server for a set of components\n */\n createDevServer(\n context: DevServerContext,\n transformers: WebpackConfigTransformer[] = [],\n webpackModulePath?: string,\n webpackDevServerModulePath?: string\n ): DevServer {\n const config = this.createDevServerConfig(\n context.entry,\n this.workspace.path,\n context.id,\n context.rootPath,\n context.publicPath,\n this.workspace.getComponentPathsRegExps(),\n context.title\n ) as any;\n const wdsPath = webpackDevServerModulePath || require.resolve('webpack-dev-server');\n const configMutator = new WebpackConfigMutator(config);\n const transformerContext: WebpackConfigDevServerTransformContext = Object.assign(context, { mode: 'dev' as const });\n const internalTransformers = this.generateTransformers(undefined, transformerContext);\n\n const afterMutation = runTransformersWithContext(\n configMutator.clone(),\n [...internalTransformers, ...transformers],\n transformerContext\n );\n // @ts-ignore - fix this\n return new WebpackDevServer(afterMutation.raw, this.getWebpackInstance(webpackModulePath, webpack), wdsPath);\n }\n\n mergeConfig(target: any, source: any): any {\n return merge(target, source);\n }\n\n createBundler(\n context: BundlerContext,\n transformers: WebpackConfigTransformer[] = [],\n initialConfigs?: webpack.Configuration[],\n webpackModuleOrPath?: string | any\n ) {\n const transformerContext: GlobalWebpackConfigTransformContext = {\n mode: 'prod',\n isEnvTemplate: context.metaData?.isEnvTemplate,\n };\n // eslint-disable-next-line max-len\n const configs =\n initialConfigs ||\n this.createConfigs(context.targets, baseConfigFactory, transformers, transformerContext, context);\n return new WebpackBundler(\n context.targets,\n configs,\n this.logger,\n this.getWebpackInstance(webpackModuleOrPath, webpack),\n context.metaData\n );\n }\n\n private createConfigs(\n targets: Target[],\n factory: (target: Target, context: BundlerContext) => Configuration,\n transformers: WebpackConfigTransformer[] = [],\n transformerContext: GlobalWebpackConfigTransformContext,\n bundlerContext: BundlerContext\n ) {\n return targets.map((target) => {\n const baseConfig = factory(target, bundlerContext);\n const configMutator = new WebpackConfigMutator(baseConfig);\n const context = Object.assign({}, transformerContext, { target });\n const internalTransformers = this.generateTransformers(context, undefined, target);\n const afterMutation = runTransformersWithContext(\n configMutator.clone(),\n [...internalTransformers, ...transformers],\n context\n );\n return afterMutation.raw;\n });\n }\n\n private generateTransformers(\n _bundlerContext?: WebpackConfigTransformContext,\n devServerContext?: WebpackConfigDevServerTransformContext,\n target?: Target\n ): Array<WebpackConfigTransformer> {\n const transformers: WebpackConfigTransformer[] = [];\n // TODO: handle dev server\n const hostDeps = target?.hostDependencies || devServerContext?.hostDependencies;\n if (hostDeps) {\n if (target?.aliasHostDependencies || devServerContext?.aliasHostDependencies) {\n const peerAliasesTransformer = generateAddAliasesFromPeersTransformer(hostDeps, this.logger);\n transformers.push(peerAliasesTransformer);\n }\n if (target?.externalizeHostDependencies || devServerContext?.externalizeHostDependencies) {\n const externalsTransformer = generateExternalsTransformer(hostDeps);\n transformers.push(externalsTransformer);\n }\n }\n return transformers;\n }\n\n private getWebpackInstance(webpackOrPath?: any | string, fallback?: any) {\n if (!webpackOrPath) {\n return fallback;\n }\n if (typeof webpackOrPath === 'string') {\n // eslint-disable-next-line import/no-dynamic-require, global-require\n return require(webpackOrPath);\n }\n return webpackOrPath;\n }\n\n private createDevServerConfig(\n entry: string[],\n rootPath: string,\n devServerID: string,\n publicRoot: string,\n publicPath: string,\n componentPathsRegExps: RegExp[],\n title?: string\n ) {\n return devServerConfigFactory(\n devServerID,\n rootPath,\n entry,\n publicRoot,\n publicPath,\n componentPathsRegExps,\n this.pubsub,\n title\n );\n }\n\n static slots = [];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, WorkspaceAspect, BundlerAspect, LoggerAspect];\n\n static async provider([pubsub, workspace, bundler, logger]: [PubsubMain, Workspace, BundlerMain, LoggerMain]) {\n const logPublisher = logger.createLogger(WebpackAspect.id);\n return new WebpackMain(pubsub, workspace, bundler, logPublisher);\n }\n}\n\nWebpackAspect.addRuntime(WebpackMain);\n\nexport function runTransformersWithContext(\n config: WebpackConfigMutator,\n transformers: Array<WebpackConfigTransformer | WebpackConfigDevServerTransformer> = [],\n // context: WebpackConfigTransformContext | WebpackConfigDevServerTransformContext\n context: any\n): WebpackConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n // @ts-ignore\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AASA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,cAAA;EAAA,MAAAR,IAAA,G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AM,EAAEC,SAAS,EAAEC,OAAO,EAAEsE,YAAY,CAAC;EAClE;AACF;AAACG,OAAA,CAAA7E,WAAA,GAAAA,WAAA;AAAApB,eAAA,CArKYoB,WAAW,WA4JP,EAAE;AAAApB,eAAA,CA5JNoB,WAAW,aA8JL8E,kBAAW;AAAAlG,eAAA,CA9JjBoB,WAAW,kBA+JA,CAAC+E,iBAAY,EAAEC,4BAAe,EAAEC,wBAAa,EAAEC,sBAAY,CAAC;AAQpFN,yBAAa,CAACO,UAAU,CAACnF,WAAW,CAAC;AAE9B,SAAS+B,0BAA0BA,CACxCpB,MAA4B,EAC5BH,YAAiF,GAAG,EAAE;AACtF;AACAD,OAAY,EACU;EACtB,IAAI,CAAC6E,KAAK,CAACC,OAAO,CAAC7E,YAAY,CAAC,EAAE,OAAOG,MAAM;EAC/C,MAAM2E,SAAS,GAAG9E,YAAY,CAAC+E,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;IAC1D;IACA,OAAOA,WAAW,CAACD,GAAG,EAAEjF,OAAO,CAAC;EAClC,CAAC,EAAEI,MAAM,CAAC;EACV,OAAO2E,SAAS;AAClB"}
|
1
|
+
{"version":3,"names":["_webpack","data","_interopRequireDefault","require","_pubsub","_bundler","_cli","_logger","_workspace","_webpackMerge","_webpackModules","_transformers","_webpackDev","_webpack2","_webpack3","_webpack4","_webpack5","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","WebpackMain","constructor","pubsub","workspace","bundler","logger","createDevServer","context","transformers","webpackModulePath","webpackDevServerModulePath","config","createDevServerConfig","entry","path","id","rootPath","publicPath","getComponentPathsRegExps","title","wdsPath","resolve","configMutator","WebpackConfigMutator","transformerContext","assign","mode","internalTransformers","generateTransformers","undefined","afterMutation","runTransformersWithContext","clone","WebpackDevServer","raw","getWebpackInstance","webpack","mergeConfig","target","source","merge","createBundler","initialConfigs","webpackModuleOrPath","isEnvTemplate","metaData","configs","createConfigs","targets","baseConfigFactory","WebpackBundler","factory","bundlerContext","map","baseConfig","_bundlerContext","devServerContext","hostDeps","hostDependencies","aliasHostDependencies","peerAliasesTransformer","generateAddAliasesFromPeersTransformer","push","externalizeHostDependencies","externalsTransformer","generateExternalsTransformer","webpackOrPath","fallback","devServerID","publicRoot","componentPathsRegExps","devServerConfigFactory","provider","logPublisher","createLogger","WebpackAspect","exports","MainRuntime","PubsubAspect","WorkspaceAspect","BundlerAspect","LoggerAspect","addRuntime","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["webpack.main.runtime.ts"],"sourcesContent":["import webpack, { Configuration } from 'webpack';\nimport PubsubAspect, { PubsubMain } from '@teambit/pubsub';\nimport {\n BundlerAspect,\n BundlerContext,\n BundlerMain,\n DevServer,\n DevServerContext,\n BundlerMode,\n Target,\n} from '@teambit/bundler';\nimport { MainRuntime } from '@teambit/cli';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { merge } from 'webpack-merge';\n// We want to import it to make sure bit recognizes it as a dependency\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport WsDevServer from 'webpack-dev-server';\nimport { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';\n\nimport { generateAddAliasesFromPeersTransformer, generateExternalsTransformer } from './transformers';\nimport { configFactory as devServerConfigFactory } from './config/webpack.dev.config';\nimport { configFactory as baseConfigFactory } from './config/webpack.config';\n\nimport { WebpackAspect } from './webpack.aspect';\nimport { WebpackBundler } from './webpack.bundler';\nimport { WebpackDevServer } from './webpack.dev-server';\n\nexport type WebpackConfigTransformContext = GlobalWebpackConfigTransformContext & {\n target: Target;\n};\n\nexport type WebpackConfigDevServerTransformContext = GlobalWebpackConfigTransformContext & DevServerContext;\n\nexport type GlobalWebpackConfigTransformContext = {\n mode: BundlerMode;\n /**\n * Whether the config is for an env template bundling\n */\n isEnvTemplate?: boolean;\n /**\n * A path for the host root dir\n * Host root dir is usually the env root dir\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n hostRootDir?: string;\n};\n\nexport type WebpackConfigTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigTransformContext\n) => WebpackConfigMutator;\n\nexport type WebpackConfigDevServerTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigDevServerTransformContext\n) => WebpackConfigMutator;\n\nexport class WebpackMain {\n constructor(\n /**\n * Pubsub extension.\n */\n public pubsub: PubsubMain,\n\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * bundler extension.\n */\n private bundler: BundlerMain,\n\n /**\n * Logger extension\n */\n public logger: Logger\n ) {}\n\n /**\n * create an instance of bit-compliant webpack dev server for a set of components\n */\n createDevServer(\n context: DevServerContext,\n transformers: WebpackConfigTransformer[] = [],\n webpackModulePath?: string,\n webpackDevServerModulePath?: string\n ): DevServer {\n const config = this.createDevServerConfig(\n context.entry,\n this.workspace.path,\n context.id,\n context.rootPath,\n context.publicPath,\n this.workspace.getComponentPathsRegExps(),\n context.title\n ) as any;\n const wdsPath = webpackDevServerModulePath || require.resolve('webpack-dev-server');\n const configMutator = new WebpackConfigMutator(config);\n const transformerContext: WebpackConfigDevServerTransformContext = Object.assign(context, { mode: 'dev' as const });\n const internalTransformers = this.generateTransformers(undefined, transformerContext);\n\n const afterMutation = runTransformersWithContext(\n configMutator.clone(),\n [...internalTransformers, ...transformers],\n transformerContext\n );\n // @ts-ignore - fix this\n return new WebpackDevServer(afterMutation.raw, this.getWebpackInstance(webpackModulePath, webpack), wdsPath);\n }\n\n mergeConfig(target: any, source: any): any {\n return merge(target, source);\n }\n\n createBundler(\n context: BundlerContext,\n transformers: WebpackConfigTransformer[] = [],\n initialConfigs?: webpack.Configuration[],\n webpackModuleOrPath?: string | any\n ) {\n const transformerContext: GlobalWebpackConfigTransformContext = {\n mode: 'prod',\n isEnvTemplate: context.metaData?.isEnvTemplate,\n };\n // eslint-disable-next-line max-len\n const configs =\n initialConfigs ||\n this.createConfigs(context.targets, baseConfigFactory, transformers, transformerContext, context);\n return new WebpackBundler(\n context.targets,\n configs,\n this.logger,\n this.getWebpackInstance(webpackModuleOrPath, webpack),\n context.metaData\n );\n }\n\n private createConfigs(\n targets: Target[],\n factory: (target: Target, context: BundlerContext) => Configuration,\n transformers: WebpackConfigTransformer[] = [],\n transformerContext: GlobalWebpackConfigTransformContext,\n bundlerContext: BundlerContext\n ) {\n return targets.map((target) => {\n const baseConfig = factory(target, bundlerContext);\n const configMutator = new WebpackConfigMutator(baseConfig);\n const context = Object.assign({}, transformerContext, { target });\n const internalTransformers = this.generateTransformers(context, undefined, target);\n const afterMutation = runTransformersWithContext(\n configMutator.clone(),\n [...internalTransformers, ...transformers],\n context\n );\n return afterMutation.raw;\n });\n }\n\n private generateTransformers(\n _bundlerContext?: WebpackConfigTransformContext,\n devServerContext?: WebpackConfigDevServerTransformContext,\n target?: Target\n ): Array<WebpackConfigTransformer> {\n const transformers: WebpackConfigTransformer[] = [];\n // TODO: handle dev server\n const hostDeps = target?.hostDependencies || devServerContext?.hostDependencies;\n if (hostDeps) {\n if (target?.aliasHostDependencies || devServerContext?.aliasHostDependencies) {\n const peerAliasesTransformer = generateAddAliasesFromPeersTransformer(hostDeps, this.logger);\n transformers.push(peerAliasesTransformer);\n }\n if (target?.externalizeHostDependencies || devServerContext?.externalizeHostDependencies) {\n const externalsTransformer = generateExternalsTransformer(hostDeps);\n transformers.push(externalsTransformer);\n }\n }\n return transformers;\n }\n\n private getWebpackInstance(webpackOrPath?: any | string, fallback?: any) {\n if (!webpackOrPath) {\n return fallback;\n }\n if (typeof webpackOrPath === 'string') {\n // eslint-disable-next-line import/no-dynamic-require, global-require\n return require(webpackOrPath);\n }\n return webpackOrPath;\n }\n\n private createDevServerConfig(\n entry: string[],\n rootPath: string,\n devServerID: string,\n publicRoot: string,\n publicPath: string,\n componentPathsRegExps: RegExp[],\n title?: string\n ) {\n return devServerConfigFactory(\n devServerID,\n rootPath,\n entry,\n publicRoot,\n publicPath,\n componentPathsRegExps,\n this.pubsub,\n title\n );\n }\n\n static slots = [];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, WorkspaceAspect, BundlerAspect, LoggerAspect];\n\n static async provider([pubsub, workspace, bundler, logger]: [PubsubMain, Workspace, BundlerMain, LoggerMain]) {\n const logPublisher = logger.createLogger(WebpackAspect.id);\n return new WebpackMain(pubsub, workspace, bundler, logPublisher);\n }\n}\n\nWebpackAspect.addRuntime(WebpackMain);\n\nexport function runTransformersWithContext(\n config: WebpackConfigMutator,\n transformers: Array<WebpackConfigTransformer | WebpackConfigDevServerTransformer> = [],\n // context: WebpackConfigTransformContext | WebpackConfigDevServerTransformContext\n context: any\n): WebpackConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n // @ts-ignore\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AASA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,OA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,EAAEC,OAAO,EAAEqE,YAAY,CAAC;EAClE;AACF;AAACG,OAAA,CAAA5E,WAAA,GAAAA,WAAA;AAAApB,eAAA,CArKYoB,WAAW,WA4JP,EAAE;AAAApB,eAAA,CA5JNoB,WAAW,aA8JL6E,kBAAW;AAAAjG,eAAA,CA9JjBoB,WAAW,kBA+JA,CAAC8E,iBAAY,EAAEC,4BAAe,EAAEC,wBAAa,EAAEC,sBAAY,CAAC;AAQpFN,yBAAa,CAACO,UAAU,CAAClF,WAAW,CAAC;AAE9B,SAAS+B,0BAA0BA,CACxCpB,MAA4B,EAC5BH,YAAiF,GAAG,EAAE;AACtF;AACAD,OAAY,EACU;EACtB,IAAI,CAAC4E,KAAK,CAACC,OAAO,CAAC5E,YAAY,CAAC,EAAE,OAAOG,MAAM;EAC/C,MAAM0E,SAAS,GAAG7E,YAAY,CAAC8E,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;IAC1D;IACA,OAAOA,WAAW,CAACD,GAAG,EAAEhF,OAAO,CAAC;EAClC,CAAC,EAAEI,MAAM,CAAC;EACV,OAAO0E,SAAS;AAClB"}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/webpack",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.109",
|
4
4
|
"homepage": "https://bit.cloud/teambit/webpack/webpack",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.webpack",
|
8
8
|
"name": "webpack",
|
9
|
-
"version": "1.0.
|
9
|
+
"version": "1.0.109"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"webpack": "5.84.1",
|
@@ -43,16 +43,14 @@
|
|
43
43
|
"expose-loader": "3.1.0",
|
44
44
|
"inject-body-webpack-plugin": "1.3.0",
|
45
45
|
"enhanced-resolve": "4.5.0",
|
46
|
-
"core-js": "^3.0.0",
|
47
|
-
"@babel/runtime": "7.20.0",
|
48
46
|
"@teambit/harmony": "0.4.6",
|
49
47
|
"@teambit/bit-error": "0.0.404",
|
50
48
|
"@teambit/webpack.modules.config-mutator": "0.0.164",
|
51
|
-
"@teambit/bundler": "1.0.
|
52
|
-
"@teambit/logger": "0.0.
|
53
|
-
"@teambit/cli": "0.0.
|
54
|
-
"@teambit/pubsub": "1.0.
|
55
|
-
"@teambit/workspace": "1.0.
|
49
|
+
"@teambit/bundler": "1.0.109",
|
50
|
+
"@teambit/logger": "0.0.934",
|
51
|
+
"@teambit/cli": "0.0.841",
|
52
|
+
"@teambit/pubsub": "1.0.109",
|
53
|
+
"@teambit/workspace": "1.0.109",
|
56
54
|
"@teambit/webpack.modules.generate-expose-loaders": "0.0.14",
|
57
55
|
"@teambit/webpack.modules.generate-externals": "0.0.15",
|
58
56
|
"@teambit/webpack.plugins.inject-head-webpack-plugin": "0.0.8"
|
@@ -60,18 +58,16 @@
|
|
60
58
|
"devDependencies": {
|
61
59
|
"@types/webpack": "5.28.1",
|
62
60
|
"@types/lodash": "4.14.165",
|
63
|
-
"@types/react": "^17.0.8",
|
64
61
|
"@types/find-root": "1.1.2",
|
65
62
|
"@types/react-dev-utils": "9.0.10",
|
66
|
-
"@types/
|
67
|
-
"@types/
|
68
|
-
"@
|
69
|
-
"@types/testing-library__jest-dom": "5.9.5"
|
63
|
+
"@types/jest": "^29.2.2",
|
64
|
+
"@types/testing-library__jest-dom": "^5.9.5",
|
65
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.14"
|
70
66
|
},
|
71
67
|
"peerDependencies": {
|
72
|
-
"@teambit/legacy": "1.0.
|
73
|
-
"react": "^
|
74
|
-
"react
|
68
|
+
"@teambit/legacy": "1.0.625",
|
69
|
+
"react": "^17.0.0 || ^18.0.0",
|
70
|
+
"@types/react": "^18.2.12"
|
75
71
|
},
|
76
72
|
"license": "Apache-2.0",
|
77
73
|
"optionalDependencies": {},
|
@@ -85,7 +81,7 @@
|
|
85
81
|
},
|
86
82
|
"private": false,
|
87
83
|
"engines": {
|
88
|
-
"node": ">=
|
84
|
+
"node": ">=16.0.0"
|
89
85
|
},
|
90
86
|
"repository": {
|
91
87
|
"type": "git",
|
@@ -94,12 +90,9 @@
|
|
94
90
|
"keywords": [
|
95
91
|
"bit",
|
96
92
|
"bit-aspect",
|
93
|
+
"bit-core-aspect",
|
97
94
|
"components",
|
98
95
|
"collaboration",
|
99
|
-
"web"
|
100
|
-
"react",
|
101
|
-
"react-components",
|
102
|
-
"angular",
|
103
|
-
"angular-components"
|
96
|
+
"web"
|
104
97
|
]
|
105
98
|
}
|
package/tsconfig.json
CHANGED
@@ -1,38 +1,33 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"lib": [
|
4
|
-
"
|
5
|
-
"
|
6
|
-
"
|
7
|
-
"DOM.Iterable",
|
8
|
-
"ScriptHost"
|
4
|
+
"esnext",
|
5
|
+
"dom",
|
6
|
+
"dom.Iterable"
|
9
7
|
],
|
10
|
-
"target": "
|
11
|
-
"module": "
|
12
|
-
"jsx": "react",
|
13
|
-
"allowJs": true,
|
14
|
-
"composite": true,
|
8
|
+
"target": "es2020",
|
9
|
+
"module": "es2020",
|
10
|
+
"jsx": "react-jsx",
|
15
11
|
"declaration": true,
|
16
12
|
"sourceMap": true,
|
17
|
-
"skipLibCheck": true,
|
18
13
|
"experimentalDecorators": true,
|
19
|
-
"
|
14
|
+
"skipLibCheck": true,
|
20
15
|
"moduleResolution": "node",
|
21
16
|
"esModuleInterop": true,
|
22
|
-
"rootDir": ".",
|
23
17
|
"resolveJsonModule": true,
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"strictPropertyInitialization": false,
|
28
|
-
"strict": true,
|
29
|
-
"noImplicitAny": false,
|
30
|
-
"preserveConstEnums": true
|
18
|
+
"allowJs": true,
|
19
|
+
"outDir": "dist",
|
20
|
+
"emitDeclarationOnly": true
|
31
21
|
},
|
32
22
|
"exclude": [
|
23
|
+
"artifacts",
|
24
|
+
"public",
|
33
25
|
"dist",
|
26
|
+
"node_modules",
|
27
|
+
"package.json",
|
34
28
|
"esm.mjs",
|
35
|
-
"
|
29
|
+
"**/*.cjs",
|
30
|
+
"./dist"
|
36
31
|
],
|
37
32
|
"include": [
|
38
33
|
"**/*",
|
package/types/asset.d.ts
CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
|
|
5
5
|
declare module '*.svg' {
|
6
6
|
import type { FunctionComponent, SVGProps } from 'react';
|
7
7
|
|
8
|
-
export const ReactComponent: FunctionComponent<
|
8
|
+
export const ReactComponent: FunctionComponent<
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
10
|
+
>;
|
9
11
|
const src: string;
|
10
12
|
export default src;
|
11
13
|
}
|
12
|
-
|
13
|
-
// @TODO Gilad
|
14
14
|
declare module '*.jpg' {
|
15
15
|
const value: any;
|
16
16
|
export = value;
|
@@ -27,3 +27,15 @@ declare module '*.bmp' {
|
|
27
27
|
const value: any;
|
28
28
|
export = value;
|
29
29
|
}
|
30
|
+
declare module '*.otf' {
|
31
|
+
const value: any;
|
32
|
+
export = value;
|
33
|
+
}
|
34
|
+
declare module '*.woff' {
|
35
|
+
const value: any;
|
36
|
+
export = value;
|
37
|
+
}
|
38
|
+
declare module '*.woff2' {
|
39
|
+
const value: any;
|
40
|
+
export = value;
|
41
|
+
}
|