diff --git a/test/fixtures/plugin-egg-plugin/config/plugin.js b/test/fixtures/plugin-egg-plugin/config/plugin.js index 29ae5932..946092ee 100644 --- a/test/fixtures/plugin-egg-plugin/config/plugin.js +++ b/test/fixtures/plugin-egg-plugin/config/plugin.js @@ -1,5 +1,3 @@ -'use strict'; - module.exports = { a: { enable: true, diff --git a/test/fixtures/plugin-pkg-exports/config/plugin.js b/test/fixtures/plugin-pkg-exports/config/plugin.js new file mode 100644 index 00000000..edb493a6 --- /dev/null +++ b/test/fixtures/plugin-pkg-exports/config/plugin.js @@ -0,0 +1,5 @@ +module.exports = { + a: { + enable: true, + }, +}; diff --git a/test/fixtures/plugin-pkg-exports/node_modules/a/foo_dist/commonjs/config/config.default.js b/test/fixtures/plugin-pkg-exports/node_modules/a/foo_dist/commonjs/config/config.default.js new file mode 100644 index 00000000..946092ee --- /dev/null +++ b/test/fixtures/plugin-pkg-exports/node_modules/a/foo_dist/commonjs/config/config.default.js @@ -0,0 +1,8 @@ +module.exports = { + a: { + enable: true, + }, + b: { + enable: true, + }, +}; diff --git a/test/fixtures/plugin-pkg-exports/node_modules/a/foo_dist/esm/config/config.default.js b/test/fixtures/plugin-pkg-exports/node_modules/a/foo_dist/esm/config/config.default.js new file mode 100644 index 00000000..a510ac69 --- /dev/null +++ b/test/fixtures/plugin-pkg-exports/node_modules/a/foo_dist/esm/config/config.default.js @@ -0,0 +1,8 @@ +export default { + a: { + enable: true, + }, + b: { + enable: true, + }, +} diff --git a/test/fixtures/plugin-pkg-exports/node_modules/a/package.json b/test/fixtures/plugin-pkg-exports/node_modules/a/package.json new file mode 100644 index 00000000..30bd88e6 --- /dev/null +++ b/test/fixtures/plugin-pkg-exports/node_modules/a/package.json @@ -0,0 +1,9 @@ +{ + "name": "a", + "eggPlugin": { + "exports": { + "require": "./foo_dist/commonjs", + "import": "./foo_dist/esm" + } + } +} diff --git a/test/fixtures/plugin-pkg-exports/package.json b/test/fixtures/plugin-pkg-exports/package.json new file mode 100644 index 00000000..28b33896 --- /dev/null +++ b/test/fixtures/plugin-pkg-exports/package.json @@ -0,0 +1,3 @@ +{ + "name": "plugin-pkg-exports" +} diff --git a/test/loader/mixin/load_plugin.test.ts b/test/loader/mixin/load_plugin.test.ts index 5a3b6c98..493a688c 100644 --- a/test/loader/mixin/load_plugin.test.ts +++ b/test/loader/mixin/load_plugin.test.ts @@ -14,14 +14,25 @@ describe('test/loader/mixin/load_plugin.test.ts', () => { app = undefined; }); - it('should exports allPlugins, appPlugins, customPlugins, eggPlugins', () => { + it('should exports allPlugins, appPlugins, customPlugins, eggPlugins', async () => { app = createApp('plugin'); const loader = app.loader; - loader.loadPlugin(); + await loader.loadPlugin(); + assert('allPlugins' in loader); + assert('appPlugins' in loader); + assert('customPlugins' in loader); + assert('eggPlugins' in loader); + }); + + it('should load plugin by pkg.eggPlugin.exports', async () => { + app = createApp('plugin-pkg-exports'); + const loader = app.loader; + await loader.loadPlugin(); assert('allPlugins' in loader); assert('appPlugins' in loader); assert('customPlugins' in loader); assert('eggPlugins' in loader); + assert(loader.plugins.a.enable); }); it('should loadConfig all plugins', async () => {