Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: enable typecheck for _config files #4954

Merged
merged 17 commits into from May 1, 2023
Merged
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .eslintrc.js
Expand Up @@ -66,6 +66,12 @@ module.exports = {
'no-undef': 'off',
'unicorn/prevent-abbreviations': 'off'
}
},
{
files: ['test/**/_config.js'],
rules: {
'no-undef': 'off'
}
}
],
parser: '@typescript-eslint/parser',
Expand Down
3 changes: 3 additions & 0 deletions test/browser/index.js
Expand Up @@ -5,6 +5,9 @@ global.performance = require('node:perf_hooks').performance;

const { basename, resolve } = require('node:path');
const fixturify = require('fixturify');
/**
* @type {import('../../src/rollup/types')} Rollup
*/
const { rollup } = require('../../browser/dist/rollup.browser.js');
const { assertFilesAreEqual, runTestSuiteWithSamples, compareError } = require('../utils.js');

Expand Down
4 changes: 2 additions & 2 deletions test/browser/samples/basic/_config.js
@@ -1,6 +1,6 @@
const { loader } = require('../../../utils.js');

module.exports = {
module.exports = defineRollupTest({
description: 'bundles files for the browser',
options: {
plugins: loader({
Expand All @@ -9,4 +9,4 @@ console.log(foo);`,
dep: `export const foo = 42;`
})
}
};
});
4 changes: 2 additions & 2 deletions test/browser/samples/missing-dependency-resolution/_config.js
@@ -1,6 +1,6 @@
const { loader } = require('../../../utils.js');

module.exports = {
module.exports = defineRollupTest({
description: 'fails if a dependency cannot be resolved',
options: {
plugins: loader({
Expand All @@ -15,4 +15,4 @@ console.log(foo);`
url: 'https://rollupjs.org/plugin-development/#a-simple-example',
watchFiles: ['main']
}
};
});
4 changes: 2 additions & 2 deletions test/browser/samples/missing-entry-resolution/_config.js
@@ -1,9 +1,9 @@
module.exports = {
module.exports = defineRollupTest({
description: 'fails if an entry cannot be resolved',
error: {
code: 'NO_FS_IN_BROWSER',
message:
'Cannot access the file system (via "path.resolve") when using the browser build of Rollup. Make sure you supply a plugin with custom resolveId and load hooks to Rollup.',
url: 'https://rollupjs.org/plugin-development/#a-simple-example'
}
};
});
4 changes: 2 additions & 2 deletions test/browser/samples/missing-load/_config.js
@@ -1,4 +1,4 @@
module.exports = {
module.exports = defineRollupTest({
description: 'fails if a file cannot be loaded',
options: {
plugins: {
Expand All @@ -14,4 +14,4 @@ module.exports = {
url: 'https://rollupjs.org/plugin-development/#a-simple-example',
watchFiles: ['main']
}
};
});
5 changes: 3 additions & 2 deletions test/browser/samples/renormalizes-external-paths/_config.js
@@ -1,13 +1,14 @@
const { join, dirname } = require('node:path').posix;

module.exports = {
module.exports = defineRollupTest({
description: 'renormalizes external paths if possible',
options: {
input: ['/main.js', '/nested/entry.js'],
external(id) {
return id.endsWith('ext');
},
plugins: {
name: 'test-plugin',
resolveId(source, importer) {
if (source.endsWith('ext.js')) {
return false;
Expand Down Expand Up @@ -44,4 +45,4 @@ import './nested-ext.js';`;
}
}
}
};
});
4 changes: 2 additions & 2 deletions test/browser/samples/supports-hashes/_config.js
@@ -1,6 +1,6 @@
const { loader } = require('../../../utils.js');

module.exports = {
module.exports = defineRollupTest({
description: 'bundles files for the browser',
options: {
input: ['main', 'dep'],
Expand All @@ -13,4 +13,4 @@ console.log(foo);`,
entryFileNames: '[name]-[hash].js'
}
}
};
});
3 changes: 3 additions & 0 deletions test/chunking-form/index.js
@@ -1,5 +1,8 @@
const { basename, resolve } = require('node:path');
const { chdir } = require('node:process');
/**
* @type {import('../../src/rollup/types')} Rollup
*/
const { rollup } = require('../../dist/rollup');
const { runTestSuiteWithSamples, assertDirectoriesAreEqual } = require('../utils.js');

Expand Down
4 changes: 2 additions & 2 deletions test/chunking-form/samples/aliasing-extensions/_config.js
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunk aliasing with extensions',
options: {
input: ['main1', 'main2', 'main3.ts']
}
};
});
@@ -1,4 +1,4 @@
module.exports = {
module.exports = defineRollupTest({
description: "allows to use amd.autoId with amd.basePath and works when concat'd into one file",
options: {
input: ['main'],
Expand Down Expand Up @@ -31,4 +31,4 @@ module.exports = {
return exports.getA();
}
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/amd-id-auto-base-path/_config.js
@@ -1,4 +1,4 @@
module.exports = {
module.exports = defineRollupTest({
description: 'allows to use amd.autoId with amd.basePath, and chunks folder',
options: {
input: ['main'],
Expand All @@ -16,4 +16,4 @@ module.exports = {
return exports.getA();
}
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/amd-id-auto/_config.js
@@ -1,4 +1,4 @@
module.exports = {
module.exports = defineRollupTest({
description: 'allows to use amd.autoId',
options: {
input: ['main'],
Expand All @@ -13,4 +13,4 @@ module.exports = {
return exports.getA();
}
}
};
});
@@ -1,6 +1,6 @@
const assert = require('node:assert');

module.exports = {
module.exports = defineRollupTest({
description:
'emits unreferenced assets if needsCodeReference is true if they are also emitted without that flag',
options: {
Expand Down Expand Up @@ -95,4 +95,4 @@ module.exports = {
}
]
}
};
});
Expand Up @@ -2,7 +2,7 @@ const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');

module.exports = {
module.exports = defineRollupTest({
description: 'does not emit unreferenced assets if needsCodeReference is true',
options: {
output: {
Expand Down Expand Up @@ -32,4 +32,4 @@ module.exports = {
}
]
}
};
});
@@ -1,4 +1,4 @@
module.exports = {
module.exports = defineRollupTest({
description: 'avoids hoisting transitive dependencies via flag',
options: {
input: ['main1.js', 'main2.js'],
Expand All @@ -7,4 +7,4 @@ module.exports = {
hoistTransitiveImports: false
}
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/basic-chunking/_config.js
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'simple chunking',
options: {
input: ['main1.js', 'main2.js']
}
};
});
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunk reassignment import deshadowing',
options: {
input: ['main1.js', 'main2.js', 'main3.js', 'main4.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunk-execution-order/_config.js
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'maintains execution order ',
options: {
input: ['main1.js', 'main2.js', 'main3.js', 'main4.js']
}
};
});
@@ -1,7 +1,7 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunk export deshadowing',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: ['main1.js', 'main2.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunk-export-renaming/_config.js
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunk export renaming',
options: {
input: ['main1.js', 'main2.js']
}
};
});
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunk import deshadowing',
options: {
input: ['main1.js', 'main2.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunk-live-bindings/_config.js
@@ -1,7 +1,7 @@
module.exports = {
module.exports = defineRollupTest({
description: 'ES module live bindings in chunks',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: ['main1.js', 'main2.js']
}
};
});
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunk with a namespace boundary',
options: {
input: ['main1.js', 'main2.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunk-naming/_config.js
@@ -1,4 +1,4 @@
module.exports = {
module.exports = defineRollupTest({
description: 'simple chunking',
options: {
input: {
Expand All @@ -10,4 +10,4 @@ module.exports = {
chunkFileNames: 'chunks/chunk.js'
}
}
};
});
@@ -1,6 +1,6 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunk variable name conflict',
options: {
input: ['main1.js', 'main2.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunking-compact/_config.js
@@ -1,4 +1,4 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunking compact and mangled output',
options: {
input: ['main1.js', 'main2.js'],
Expand All @@ -7,4 +7,4 @@ module.exports = {
compact: true
}
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunking-externals/_config.js
@@ -1,7 +1,7 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunking external module handling',
options: {
input: ['main1.js', 'main2.js'],
external: ['external']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunking-reexport/_config.js
@@ -1,7 +1,7 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunking star external',
options: {
input: ['main1.js', 'main2.js'],
external: ['external']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunking-source-maps/_config.js
@@ -1,9 +1,9 @@
module.exports = {
module.exports = defineRollupTest({
description: 'source maps',
options: {
input: ['main1.js', 'main2.js'],
output: {
sourcemap: true
}
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/chunking-star-external/_config.js
@@ -1,7 +1,7 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunking star external',
options: {
input: ['main1.js', 'main2.js'],
external: ['external1', 'external2', 'starexternal1', 'starexternal2']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/circular-entry-points/_config.js
@@ -1,7 +1,7 @@
module.exports = {
module.exports = defineRollupTest({
description: 'chunking circular entry points',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: ['main1.js', 'main2.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/circular-entry-points2/_config.js
@@ -1,7 +1,7 @@
module.exports = {
module.exports = defineRollupTest({
description: 'does not create a facade for one circular entry point if possible',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: ['main1.js', 'main2.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/circular-entry-points3/_config.js
@@ -1,8 +1,8 @@
module.exports = {
module.exports = defineRollupTest({
description:
'creates facades for all circular entry points if they become tainted by another entry',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: ['main1.js', 'main2.js', 'main3.js']
}
};
});
4 changes: 2 additions & 2 deletions test/chunking-form/samples/circular-manual-chunks/_config.js
@@ -1,8 +1,8 @@
module.exports = {
module.exports = defineRollupTest({
description: 'handles manual chunks with circular dependencies',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: 'main',
output: { manualChunks: { lib1: ['lib1'], lib2: ['lib2'] } }
}
};
});