| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/pnp-webpack-plugin/ |
Upload File : |
const path = require(`path`);
let PnpWebpackPlugin = require(`./index`);
function makeResolver(resolverPlugins, options = {}) {
const {
NodeJsInputFileSystem,
CachedInputFileSystem,
ResolverFactory
} = require('enhanced-resolve');
const resolver = ResolverFactory.createResolver({
fileSystem: new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000),
extensions: ['.js', '.json'],
... options,
});
for (const {apply} of resolverPlugins)
apply(resolver);
return resolver;
}
function makeRequest(resolver, request, issuer) {
return new Promise((resolve, reject) => {
resolver.resolve({}, issuer, request, {}, (err, filepath) => {
if (err) {
reject(err);
} else {
resolve(filepath);
}
});
});
}
describe(`Regular Plugin`, () => {
it(`should correctly resolve a relative require`, async () => {
const resolver = makeResolver([PnpWebpackPlugin]);
const resolution = await makeRequest(resolver, `./index.js`, __dirname);
expect(resolution).toEqual(path.normalize(`${__dirname}/index.js`));
});
it(`shouldn't prevent the 'extensions' option from working`, async () => {
const resolver = makeResolver([PnpWebpackPlugin]);
const resolution = await makeRequest(resolver, `./index`, __dirname);
expect(resolution).toEqual(path.normalize(`${__dirname}/index.js`));
});
it(`shouldn't prevent the 'alias' option from working`, async () => {
const resolver = makeResolver([PnpWebpackPlugin], {alias: {[`foo`]: `./fixtures/index.js`}});
const resolution = await makeRequest(resolver, `foo`, __dirname);
expect(resolution).toEqual(path.normalize(`${__dirname}/fixtures/index.js`));
});
it(`shouldn't prevent the 'modules' option from working`, async () => {
const resolver = makeResolver([PnpWebpackPlugin], {modules: [`./fixtures`]});
const resolution = await makeRequest(resolver, `file`, __dirname);
expect(resolution).toEqual(path.normalize(`${__dirname}/fixtures/file.js`));
});
});