Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Nov 9, 2023
2 parents 29d8b10 + 2c58b01 commit bd5c070
Show file tree
Hide file tree
Showing 60 changed files with 291 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ jobs:
uses: clowdhaus/actions/[email protected]
with:
on-fail-message: "Your PR title doesn't match the required format. The title should be in the conventional commit (https://www.conventionalcommits.org/en/v1.0.0-beta.4/) format. e.g.\n\n```\nchore(plugin-name): add pr title workflow\n```"
title-regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([\w|,|\-|\|]+\))?(!)?\:\s.*$'
title-regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(([*]|[\w|,|\-|\|]+)\))?(!)?\:\s.*'
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
run: |
git pull --force --no-tags origin master:master
git checkout master
git fetch --tags
- name: Setup Node
uses: actions/setup-node@v3
Expand All @@ -38,7 +39,7 @@ jobs:
id: pnpm-setup
run: |
corepack enable
corepack prepare pnpm@latest --activate
corepack prepare pnpm@8 --activate
pnpm config set script-shell "/usr/bin/bash"
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint:js": "eslint --cache packages scripts shared util --ext .js,.ts,.mjs",
"lint:json": "prettier --write .github/**/*.yml **/tsconfig.json tsconfig.*.json pnpm-workspace.yaml",
"lint:package": "prettier --write **/package.json",
"plugin:release": "ts-node ./scripts/release.ts",
"package:release": "versioner --stripShortName='^@.+/plugin-' --target",
"preinstall": "node scripts/disallow-npm.js",
"prepare": "husky install",
"prettier": "prettier --write .",
Expand All @@ -18,6 +18,7 @@
},
"devDependencies": {
"@ava/babel": "2.0.0",
"@dot/versioner": "^0.3.1",
"@rollup/plugin-typescript": "^9.0.1",
"@types/conventional-commits-parser": "^3.0.2",
"@types/node": "14.18.30",
Expand Down
2 changes: 1 addition & 1 deletion packages/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auto-install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/beep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ci:lint": "pnpm lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "ava --verbose",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/buble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"prepublishOnly": "pnpm build",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/data-uri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build --sourcemap",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/dsv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava"
},
"files": [
Expand Down
8 changes: 8 additions & 0 deletions packages/dynamic-import-vars/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-dynamic-import-vars ChangeLog

## v2.1.0

_2023-10-25_

### Features

- feat: Error when files not found (#1611)

## v2.0.7

_2023-10-15_
Expand Down
7 changes: 7 additions & 0 deletions packages/dynamic-import-vars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ Default: `[]`

Files to exclude in this plugin (default none).

#### `errorWhenNoFilesFound`

Type: `Boolean`<br>
Default: `false`

By default, the plugin will not throw errors when target files are not found. Setting this option to true will result in errors thrown when encountering files which don't exist.

#### `warnOnError`

Type: `Boolean`<br>
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamic-import-vars/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-dynamic-import-vars",
"version": "2.0.7",
"version": "2.1.0",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build --sourcemap",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava"
},
"files": [
Expand Down
10 changes: 9 additions & 1 deletion packages/dynamic-import-vars/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createFilter } from '@rollup/pluginutils';

import { dynamicImportToGlob, VariableDynamicImportError } from './dynamic-import-to-glob';

function dynamicImportVariables({ include, exclude, warnOnError } = {}) {
function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFilesFound } = {}) {
const filter = createFilter(include, exclude);

return {
Expand Down Expand Up @@ -55,6 +55,14 @@ function dynamicImportVariables({ include, exclude, warnOnError } = {}) {
r.startsWith('./') || r.startsWith('../') ? r : `./${r}`
);

if (errorWhenNoFilesFound && paths.length === 0) {
this.error(
new Error(
`No files found in ${glob} when trying to dynamically load concatted string from ${id}`
)
);
}

// create magic string if it wasn't created already
ms = ms || new MagicString(code);
// unpack variable dynamic import into a function with import statements per file, rollup
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function importModule(name) {
return import(`./module-dir-c/${name}.js`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,35 @@ test('dynamic imports assertions', async (t) => {
);
t.snapshot(output[0].code);
});

test("doesn't throw if no files in dir when option isn't set", async (t) => {
let thrown = false;
try {
await rollup({
input: 'fixture-no-files.js',
plugins: [dynamicImportVars()]
});
} catch (_) {
thrown = true;
}
t.false(thrown);
});

test('throws if no files in dir when option is set', async (t) => {
let thrown = false;
try {
await rollup({
input: 'fixture-no-files.js',
plugins: [dynamicImportVars({ errorWhenNoFilesFound: true })]
});
} catch (error) {
t.deepEqual(
error.message,
`No files found in ./module-dir-c/*.js when trying to dynamically load concatted string from ${require.resolve(
'./fixtures/fixture-no-files.js'
)}`
);
thrown = true;
}
t.true(thrown);
});
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,25 @@ Generated by [AVA](https://avajs.dev).
export { importModule };␊
`

## no files in dir

> Snapshot 1
`function __variableDynamicImportRuntime0__(path) {␊
switch (path) {␊
default: return new Promise(function(resolve, reject) {␊
(typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(␊
reject.bind(null, new Error("Unknown variable dynamic import: " + path))␊
);␊
})␊
}␊
}␊
function importModule(name) {␊
return __variableDynamicImportRuntime0__(\`./module-dir-c/${name}.js\`);␊
}␊
export { importModule };␊
`
Binary file not shown.
6 changes: 6 additions & 0 deletions packages/dynamic-import-vars/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ interface RollupDynamicImportVariablesOptions {
* By default no files are ignored.
*/
exclude?: FilterPattern;
/**
* By default, the plugin will not throw errors when target files are not found.
* Setting this option to true will result in errors thrown when encountering files which don't exist.
* @default false
*/
errorWhenNoFilesFound?: boolean;
/**
* By default, the plugin quits the build process when it encounters an error.
* If you set this option to true, it will throw a warning instead and leave the code untouched.
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/esm-shim/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-esm-shim ChangeLog

## v0.1.5

_2023-11-05_

### Updates

- refactor: use prefix for build in module imports (#1622)

## v0.1.4

_2023-10-15_
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-shim/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-esm-shim",
"version": "0.1.4",
"version": "0.1.5",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-shim/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export const CJSyntaxRegex = /__filename|__dirname|require\(|require\.resolve\(/

export const ESMShim = `
// -- Shims --
import cjsUrl from 'url';
import cjsPath from 'path';
import cjsModule from 'module';
import cjsUrl from 'node:url';
import cjsPath from 'node:path';
import cjsModule from 'node:module';
const __filename = cjsUrl.fileURLToPath(import.meta.url);
const __dirname = cjsPath.dirname(__filename);
const require = cjsModule.createRequire(import.meta.url);
Expand Down
24 changes: 12 additions & 12 deletions packages/esm-shim/test/snapshots/test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Generated by [AVA](https://avajs.dev).
`␊
// -- Shims --␊
import cjsUrl from 'url';␊
import cjsPath from 'path';␊
import cjsModule from 'module';␊
import cjsUrl from 'node:url';␊
import cjsPath from 'node:path';␊
import cjsModule from 'node:module';␊
const __filename = cjsUrl.fileURLToPath(import.meta.url);␊
const __dirname = cjsPath.dirname(__filename);␊
const require = cjsModule.createRequire(import.meta.url);␊
Expand All @@ -27,9 +27,9 @@ Generated by [AVA](https://avajs.dev).
`␊
// -- Shims --␊
import cjsUrl from 'url';␊
import cjsPath from 'path';␊
import cjsModule from 'module';␊
import cjsUrl from 'node:url';␊
import cjsPath from 'node:path';␊
import cjsModule from 'node:module';␊
const __filename = cjsUrl.fileURLToPath(import.meta.url);␊
const __dirname = cjsPath.dirname(__filename);␊
const require = cjsModule.createRequire(import.meta.url);␊
Expand Down Expand Up @@ -58,9 +58,9 @@ Generated by [AVA](https://avajs.dev).
// -- Shims --␊
import cjsUrl from 'url';␊
import cjsPath from 'path';␊
import cjsModule from 'module';␊
import cjsUrl from 'node:url';␊
import cjsPath from 'node:path';␊
import cjsModule from 'node:module';␊
const __filename = cjsUrl.fileURLToPath(import.meta.url);␊
const __dirname = cjsPath.dirname(__filename);␊
const require = cjsModule.createRequire(import.meta.url);␊
Expand All @@ -80,9 +80,9 @@ Generated by [AVA](https://avajs.dev).
// -- Shims --␊
import cjsUrl from 'url';␊
import cjsPath from 'path';␊
import cjsModule from 'module';␊
import cjsUrl from 'node:url';␊
import cjsPath from 'node:path';␊
import cjsModule from 'node:module';␊
const __filename = cjsUrl.fileURLToPath(import.meta.url);␊
const __dirname = cjsPath.dirname(__filename);␊
const require = cjsModule.createRequire(import.meta.url);␊
Expand Down
Binary file modified packages/esm-shim/test/snapshots/test.js.snap
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava"
},
"files": [
Expand Down
Loading

0 comments on commit bd5c070

Please sign in to comment.