@teambit/react 0.0.733 → 0.0.734
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/env-template/public/{283.js → 149.js} +2 -2
- package/artifacts/env-template/public/{793.js → 295.js} +61 -61
- package/artifacts/env-template/public/677.js +5 -5
- package/artifacts/env-template/public/750.js +6 -6
- package/artifacts/env-template/public/927.js +34 -0
- package/artifacts/env-template/public/994.js +5 -5
- package/artifacts/env-template/public/assets-manifest.json +18 -18
- package/artifacts/env-template/public/{compositions.82ccc8620b733a9449f2.js → compositions.32c4d8736482f93f0173.js} +1 -1
- package/artifacts/env-template/public/compositions.html +1 -1
- package/artifacts/env-template/public/{overview.34502204d838991d8919.js → overview.d5bb4ae4fedfa13c9554.js} +1 -1
- package/artifacts/env-template/public/overview.html +1 -1
- package/artifacts/env-template/public/peers.edfbd1f8ec8a3331b9ac.js +1 -0
- package/artifacts/env-template/public/{preview-root.16e0164b42f482636a15.js → preview-root.b22a871992aa18281157.js} +1 -1
- package/artifacts/env-template/public/service-worker.js +1 -1
- package/artifacts/env-template/public/static/css/{793.e370e333.css → 295.e370e333.css} +0 -0
- package/artifacts/preview/teambit_react_react-preview.js +2 -2
- package/{compositions-1652757984397.js → compositions-1652785756723.js} +0 -0
- package/dist/react.env.js +2 -1
- package/dist/react.env.js.map +1 -1
- package/dist/webpack/get-exposed-rules.d.ts +2 -1
- package/dist/webpack/get-exposed-rules.js +12 -2
- package/dist/webpack/get-exposed-rules.js.map +1 -1
- package/dist/webpack/resolve-peer.d.ts +14 -0
- package/dist/webpack/resolve-peer.js +108 -0
- package/dist/webpack/resolve-peer.js.map +1 -0
- package/dist/webpack/transformers.d.ts +8 -1
- package/dist/webpack/transformers.js +34 -40
- package/dist/webpack/transformers.js.map +1 -1
- package/dist/webpack/webpack.config.base.prod.js +0 -15
- package/dist/webpack/webpack.config.base.prod.js.map +1 -1
- package/{overview-1652757984397.js → overview-1652785756723.js} +0 -0
- package/package-tar/teambit-react-0.0.734.tgz +0 -0
- package/package.json +28 -27
- package/{preview-1652757984397.js → preview-1652785756723.js} +2 -2
- package/webpack/get-exposed-rules.ts +4 -2
- package/webpack/resolve-peer.ts +60 -0
- package/webpack/transformers.ts +24 -33
- package/webpack/webpack.config.base.prod.ts +0 -9
- package/artifacts/env-template/public/557.js +0 -34
- package/artifacts/env-template/public/peers.dbfbae2daf17fd0c329d.js +0 -1
- package/package-tar/teambit-react-0.0.733.tgz +0 -0
package/webpack/transformers.ts
CHANGED
|
@@ -1,46 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { WebpackConfigTransformContext } from '@teambit/webpack';
|
|
2
2
|
import { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';
|
|
3
3
|
import { Logger } from '@teambit/logger';
|
|
4
|
+
import { getExposedRules } from './get-exposed-rules';
|
|
5
|
+
import { resolvePeerToDirOrFile } from './resolve-peer';
|
|
4
6
|
|
|
5
7
|
export function generateAddAliasesFromPeersTransformer(peers: string[], logger: Logger) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
acc
|
|
18
|
-
}
|
|
19
|
-
return acc;
|
|
20
|
-
}, {});
|
|
21
|
-
return (config: WebpackConfigMutator): WebpackConfigMutator => {
|
|
8
|
+
return (config: WebpackConfigMutator, context: WebpackConfigTransformContext): WebpackConfigMutator => {
|
|
9
|
+
const peerAliases = peers.reduce((acc, peerName) => {
|
|
10
|
+
// gets the correct module folder of the package.
|
|
11
|
+
// this allows us to resolve internal files, for example:
|
|
12
|
+
// node_modules/react-dom/test-utils
|
|
13
|
+
//
|
|
14
|
+
// we can't use require.resolve() because it resolves to a specific file.
|
|
15
|
+
// for example, if we used "react-dom": require.resolve("react-dom"),
|
|
16
|
+
// it would try to resolve "react-dom/test-utils" as:
|
|
17
|
+
// node_modules/react-dom/index.js/test-utils
|
|
18
|
+
acc[peerName] = resolvePeerToDirOrFile(peerName, logger, context.target.hostRootDir);
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
22
21
|
config.addAliases(peerAliases);
|
|
23
22
|
return config;
|
|
24
23
|
};
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param
|
|
27
|
+
* Generate a transformer that expose all the peers as global via the expose loader
|
|
28
|
+
* @param peers
|
|
30
29
|
* @returns
|
|
31
30
|
*/
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} catch (e) {
|
|
39
|
-
if (resolved) {
|
|
40
|
-
logger.warn(`Couldn't find root dir for "${peerName}" from path "${resolved}" to add it as webpack alias`);
|
|
41
|
-
} else {
|
|
42
|
-
logger.warn(`Couldn't resolve "${peerName}" to add it as webpack alias`);
|
|
43
|
-
}
|
|
44
|
-
return resolved;
|
|
45
|
-
}
|
|
31
|
+
export function generateExposePeersTransformer(peers: string[], logger: Logger) {
|
|
32
|
+
return (config: WebpackConfigMutator, context: WebpackConfigTransformContext): WebpackConfigMutator => {
|
|
33
|
+
const exposedRules = getExposedRules(peers, logger, context.target.hostRootDir);
|
|
34
|
+
config.addModuleRules(exposedRules);
|
|
35
|
+
return config;
|
|
36
|
+
};
|
|
46
37
|
}
|
|
@@ -3,7 +3,6 @@ import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
|
3
3
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
4
4
|
import { Configuration } from 'webpack';
|
|
5
5
|
import { getExternals } from './get-externals';
|
|
6
|
-
import { getExposedRules } from './get-exposed-rules';
|
|
7
6
|
// import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
|
|
8
7
|
|
|
9
8
|
// This is the production and development configuration.
|
|
@@ -11,13 +10,6 @@ import { getExposedRules } from './get-exposed-rules';
|
|
|
11
10
|
// eslint-disable-next-line complexity
|
|
12
11
|
export default function (externalizePeer: boolean, peers: string[], dev?: boolean): Configuration {
|
|
13
12
|
const externals = externalizePeer ? (getExternals(peers) as any) : undefined;
|
|
14
|
-
const exposedRules = externalizePeer ? undefined : getExposedRules(peers);
|
|
15
|
-
|
|
16
|
-
const module = externalizePeer
|
|
17
|
-
? undefined
|
|
18
|
-
: {
|
|
19
|
-
rules: exposedRules,
|
|
20
|
-
};
|
|
21
13
|
|
|
22
14
|
const optimization = dev
|
|
23
15
|
? undefined
|
|
@@ -105,7 +97,6 @@ export default function (externalizePeer: boolean, peers: string[], dev?: boolea
|
|
|
105
97
|
};
|
|
106
98
|
|
|
107
99
|
return {
|
|
108
|
-
module,
|
|
109
100
|
externals,
|
|
110
101
|
optimization,
|
|
111
102
|
|