diff --git a/packages/enhanced/src/lib/sharing/SharePlugin.ts b/packages/enhanced/src/lib/sharing/SharePlugin.ts index 1b8edb4e9c..065196158e 100644 --- a/packages/enhanced/src/lib/sharing/SharePlugin.ts +++ b/packages/enhanced/src/lib/sharing/SharePlugin.ts @@ -68,8 +68,6 @@ class SharePlugin { requiredVersion: options.requiredVersion, strictVersion: options.strictVersion, singleton: options.singleton, - issuerLayer: options.issuerLayer, - requiredLayer: options.requiredLayer, }, })); //@ts-ignore diff --git a/packages/enhanced/test/configCases/sharing/layers/.gitignore b/packages/enhanced/test/configCases/sharing/layers-consume-entry/.gitignore similarity index 100% rename from packages/enhanced/test/configCases/sharing/layers/.gitignore rename to packages/enhanced/test/configCases/sharing/layers-consume-entry/.gitignore diff --git a/packages/enhanced/test/configCases/sharing/layers-consume-entry/async-boundary.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/async-boundary.js new file mode 100644 index 0000000000..33145c331a --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-consume-entry/async-boundary.js @@ -0,0 +1 @@ +export * from 'react'; diff --git a/packages/enhanced/test/configCases/sharing/layers-consume-entry/index-test.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/index-test.js new file mode 100644 index 0000000000..9a2597f644 --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-consume-entry/index-test.js @@ -0,0 +1,5 @@ +it('should load module with correct layer from entry layer', async () => { + const { version, layer } = await import('./async-boundary'); + expect(version).toBe('1.0.0'); + expect(layer).toBe('module-layer'); +}); diff --git a/packages/enhanced/test/configCases/sharing/layers-consume-entry/index.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/index.js new file mode 100644 index 0000000000..18f91c06af --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-consume-entry/index.js @@ -0,0 +1 @@ +import './index-test'; diff --git a/packages/enhanced/test/configCases/sharing/layers/layer-exporter.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/layer-exporter.js similarity index 52% rename from packages/enhanced/test/configCases/sharing/layers/layer-exporter.js rename to packages/enhanced/test/configCases/sharing/layers-consume-entry/layer-exporter.js index 7f9edc9a64..3fcd00e9f4 100644 --- a/packages/enhanced/test/configCases/sharing/layers/layer-exporter.js +++ b/packages/enhanced/test/configCases/sharing/layers-consume-entry/layer-exporter.js @@ -1,7 +1,4 @@ module.exports = function layerLoader(source) { // Inject the layer name as an export - return [ - source, - 'export const layer = "react-layer";' - ].join('\n'); + return [source, 'export const layer = "module-layer";'].join('\n'); }; diff --git a/packages/enhanced/test/configCases/sharing/layers/node_modules/react/index.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/node_modules/react/index.js similarity index 100% rename from packages/enhanced/test/configCases/sharing/layers/node_modules/react/index.js rename to packages/enhanced/test/configCases/sharing/layers-consume-entry/node_modules/react/index.js diff --git a/packages/enhanced/test/configCases/sharing/layers/node_modules/react/index2.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/node_modules/react/index2.js similarity index 100% rename from packages/enhanced/test/configCases/sharing/layers/node_modules/react/index2.js rename to packages/enhanced/test/configCases/sharing/layers-consume-entry/node_modules/react/index2.js diff --git a/packages/enhanced/test/configCases/sharing/layers/package.json b/packages/enhanced/test/configCases/sharing/layers-consume-entry/package.json similarity index 100% rename from packages/enhanced/test/configCases/sharing/layers/package.json rename to packages/enhanced/test/configCases/sharing/layers-consume-entry/package.json diff --git a/packages/enhanced/test/configCases/sharing/layers/test.config.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/test.config.js similarity index 100% rename from packages/enhanced/test/configCases/sharing/layers/test.config.js rename to packages/enhanced/test/configCases/sharing/layers-consume-entry/test.config.js diff --git a/packages/enhanced/test/configCases/sharing/layers-consume-entry/webpack.config.js b/packages/enhanced/test/configCases/sharing/layers-consume-entry/webpack.config.js new file mode 100644 index 0000000000..30e05dbfbe --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-consume-entry/webpack.config.js @@ -0,0 +1,39 @@ +const { ConsumeSharedPlugin } = require('../../../../dist/src'); +const path = require('path'); + +module.exports = { + mode: 'development', + devtool: false, + entry: { + main: { + import: './index.js', + layer: 'entry-layer', + }, + }, + experiments: { + layers: true, + }, + module: { + rules: [ + { + test: /async-boundary\.js$/, + issuerLayer: 'entry-layer', + use: [ + { + loader: path.resolve(__dirname, './layer-exporter.js'), + }, + ], + }, + ], + }, + plugins: [ + new ConsumeSharedPlugin({ + consumes: { + react: { + singleton: true, + shareKey: 'react', + }, + }, + }), + ], +}; diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/.gitignore b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/.gitignore new file mode 100644 index 0000000000..d50bf9e819 --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/.gitignore @@ -0,0 +1 @@ +node_modules/.federation diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/async-boundary.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/async-boundary.js new file mode 100644 index 0000000000..33145c331a --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/async-boundary.js @@ -0,0 +1 @@ +export * from 'react'; diff --git a/packages/enhanced/test/configCases/sharing/layers/differing-layer.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/differing-layer.js similarity index 51% rename from packages/enhanced/test/configCases/sharing/layers/differing-layer.js rename to packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/differing-layer.js index e30fd34620..0cdd119c08 100644 --- a/packages/enhanced/test/configCases/sharing/layers/differing-layer.js +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/differing-layer.js @@ -1,7 +1,4 @@ module.exports = function layerLoader(source) { // Inject the layer name as an export - return [ - source, - 'export const layer = "differing-layer";' - ].join('\n'); + return [source, 'export const layer = "differing-layer";'].join('\n'); }; diff --git a/packages/enhanced/test/configCases/sharing/layers/differing-test.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/differing-test.js similarity index 75% rename from packages/enhanced/test/configCases/sharing/layers/differing-test.js rename to packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/differing-test.js index 77f6085cf4..271fb04be2 100644 --- a/packages/enhanced/test/configCases/sharing/layers/differing-test.js +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/differing-test.js @@ -1,11 +1,11 @@ it('Module graph should have a layer different layer', async () => { - const {version, layer} = (await import('react')); + const { version, layer } = await import('react'); expect(version).toBe('1.0.0'); expect(layer).toBe('differing-layer'); }); it('Module graph should have a layer set explicitly thats not the inherited issuerLayer', async () => { - const {dix, layer} = (await import('react/index2')); + const { dix, layer } = await import('react/index2'); expect(dix).toBe('1.0.0'); expect(layer).toBe('explicit-layer'); }); diff --git a/packages/enhanced/test/configCases/sharing/layers/explicit-layer.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/explicit-layer.js similarity index 52% rename from packages/enhanced/test/configCases/sharing/layers/explicit-layer.js rename to packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/explicit-layer.js index 62ac7eb79f..e517886c9e 100644 --- a/packages/enhanced/test/configCases/sharing/layers/explicit-layer.js +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/explicit-layer.js @@ -1,7 +1,4 @@ module.exports = function layerLoader(source) { // Inject the layer name as an export - return [ - source, - 'export const layer = "explicit-layer";' - ].join('\n'); + return [source, 'export const layer = "explicit-layer";'].join('\n'); }; diff --git a/packages/enhanced/test/configCases/sharing/layers/index-test.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/index-test.js similarity index 67% rename from packages/enhanced/test/configCases/sharing/layers/index-test.js rename to packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/index-test.js index 1efce00298..fba4a98ac1 100644 --- a/packages/enhanced/test/configCases/sharing/layers/index-test.js +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/index-test.js @@ -1,5 +1,5 @@ it('Module Graph should have layerd share', async () => { - const {version, layer} = (await import('./async-boundary')); + const { version, layer } = await import('./async-boundary'); expect(version).toBe('1.0.0'); expect(layer).toBe('react-layer'); }); diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/index.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/index.js new file mode 100644 index 0000000000..a9b3297b07 --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/index.js @@ -0,0 +1,3 @@ +import './index-test'; +import './other-test'; +import './differing-test'; diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/layer-exporter.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/layer-exporter.js new file mode 100644 index 0000000000..2312ffcb0a --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/layer-exporter.js @@ -0,0 +1,4 @@ +module.exports = function layerLoader(source) { + // Inject the layer name as an export + return [source, 'export const layer = "react-layer";'].join('\n'); +}; diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/node_modules/react/index.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/node_modules/react/index.js new file mode 100644 index 0000000000..17f0c46768 --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/node_modules/react/index.js @@ -0,0 +1,2 @@ +import { dix } from './index2'; +export const version = "1.0.0"; diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/node_modules/react/index2.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/node_modules/react/index2.js new file mode 100644 index 0000000000..6aa19f3b6b --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/node_modules/react/index2.js @@ -0,0 +1 @@ +export const dix = "1.0.0"; diff --git a/packages/enhanced/test/configCases/sharing/layers/other-test.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/other-test.js similarity index 66% rename from packages/enhanced/test/configCases/sharing/layers/other-test.js rename to packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/other-test.js index d07460b36b..117ad87c14 100644 --- a/packages/enhanced/test/configCases/sharing/layers/other-test.js +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/other-test.js @@ -1,5 +1,5 @@ it('Module Graph should unlayered share', async () => { - const {version, layer} = (await import('./async-boundary')); + const { version, layer } = await import('./async-boundary'); expect(version).toBe('1.0.0'); expect(layer).toBeUndefined(); }); diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/other.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/other.js new file mode 100644 index 0000000000..00fb240dd2 --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/other.js @@ -0,0 +1 @@ +import './other-test'; diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/package.json b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/package.json new file mode 100644 index 0000000000..630a229094 --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/package.json @@ -0,0 +1,11 @@ +{ + "name": "layered-react-test", + "version": "1.0.0", + "private": true, + "scripts": { + "build": "webpack --config=webpack.config.js" + }, + "dependencies": { + "react": "1.0.0" + } +} diff --git a/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/test.config.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/test.config.js new file mode 100644 index 0000000000..e2c700f280 --- /dev/null +++ b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/test.config.js @@ -0,0 +1,6 @@ +module.exports = { + layers: true, + findBundle: function () { + return ['bundle0.js']; + }, +}; diff --git a/packages/enhanced/test/configCases/sharing/layers/webpack.config.js b/packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/webpack.config.js similarity index 100% rename from packages/enhanced/test/configCases/sharing/layers/webpack.config.js rename to packages/enhanced/test/configCases/sharing/layers-loaders-no-entry/webpack.config.js diff --git a/packages/enhanced/test/configCases/sharing/layers/async-boundary.js b/packages/enhanced/test/configCases/sharing/layers/async-boundary.js deleted file mode 100644 index 2d1b281a56..0000000000 --- a/packages/enhanced/test/configCases/sharing/layers/async-boundary.js +++ /dev/null @@ -1 +0,0 @@ -export * from "react"; diff --git a/packages/enhanced/test/configCases/sharing/layers/index.js b/packages/enhanced/test/configCases/sharing/layers/index.js deleted file mode 100644 index 3842b33206..0000000000 --- a/packages/enhanced/test/configCases/sharing/layers/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import "./index-test"; -import "./other-test"; -import "./differing-test" diff --git a/packages/enhanced/test/configCases/sharing/layers/other.js b/packages/enhanced/test/configCases/sharing/layers/other.js deleted file mode 100644 index 2cb5d3047b..0000000000 --- a/packages/enhanced/test/configCases/sharing/layers/other.js +++ /dev/null @@ -1 +0,0 @@ -import "./other-test"