Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feat/typed-test-c…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
lukastaegert committed May 1, 2023
2 parents 9db29e0 + 4fb9778 commit fceb680
Show file tree
Hide file tree
Showing 58 changed files with 4,586 additions and 6,594 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,32 @@
# rollup changelog

## 3.21.2

_2023-04-30_

### Bug Fixes

- Mark global functions that trigger iterators as impure for now (#4955)

### Pull Requests

- [#4955](https://github.com/rollup/rollup/pull/4955): fix: mark some known globals or their functions as impure (@TrickyPi)

## 3.21.1

_2023-04-29_

### Bug Fixes

- Make sure call arguments are properly deoptimized when a function uses the `arguments` variable (#4965)

### Pull Requests

- [#4957](https://github.com/rollup/rollup/pull/4957): Update dependencies (@lukastaegert)
- [#4964](https://github.com/rollup/rollup/pull/4964): Fix REPL in dev (@lukastaegert)
- [#4965](https://github.com/rollup/rollup/pull/4965): Ensure arguments are deoptimized when arguments variable is used (@lukastaegert)
- [#4967](https://github.com/rollup/rollup/pull/4967): Log REPL output to console (@lukastaegert)

## 3.21.0

_2023-04-23_
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Expand Up @@ -611,7 +611,7 @@ Repository: https://github.com/tapjs/signal-exit.git

> The ISC License
>
> Copyright (c) 2015, Contributors
> Copyright (c) 2015-2023 Benjamin Coe, Isaac Z. Schlueter, and Contributors
>
> Permission to use, copy, modify, and/or distribute this software
> for any purpose with or without fee is hereby granted, provided
Expand Down
2 changes: 1 addition & 1 deletion browser/package.json
@@ -1,6 +1,6 @@
{
"name": "@rollup/browser",
"version": "3.21.0",
"version": "3.21.2",
"description": "Next-generation ES module bundler browser build",
"main": "dist/rollup.browser.js",
"module": "dist/es/rollup.browser.js",
Expand Down
13 changes: 10 additions & 3 deletions build-plugins/replace-browser-modules.ts
@@ -1,6 +1,6 @@
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { Plugin } from 'rollup';
import type { Plugin } from 'vite';

const resolve = (path: string) => fileURLToPath(new URL(`../${path}`, import.meta.url));

Expand All @@ -14,10 +14,10 @@ const REPLACED_MODULES = [
'resolveId'
];

export const resolutions: ReadonlyMap<string, string> = new Map(
const resolutions: ReadonlyMap<string, string> = new Map(
REPLACED_MODULES.flatMap(module => {
const originalId = resolve(`src/utils/${module}`);
const replacementId = resolve(`browser/src//${module}.ts`);
const replacementId = resolve(`browser/src/${module}.ts`);
return [
[originalId, replacementId],
[`${originalId}.ts`, replacementId]
Expand All @@ -27,11 +27,18 @@ export const resolutions: ReadonlyMap<string, string> = new Map(

export default function replaceBrowserModules(): Plugin {
return {
apply: 'serve',
enforce: 'pre',
name: 'replace-browser-modules',
resolveId(source, importer) {
if (importer && source[0] === '.') {
return resolutions.get(join(dirname(importer), source));
}
},
transformIndexHtml(html) {
// Unfortunately, picomatch sneaks as a dedendency into the dev bundle.
// This fixes an error.
return html.replace('</head>', '<script>window.process={}</script></head>');
}
};
}
4 changes: 2 additions & 2 deletions cli/run/watch-cli.ts
Expand Up @@ -4,7 +4,7 @@ import process from 'node:process';
import chokidar from 'chokidar';
import dateTime from 'date-time';
import ms from 'pretty-ms';
import onExit from 'signal-exit';
import { onExit } from 'signal-exit';
import * as rollup from '../../src/node-entry';
import type { MergedRollupOptions, RollupWatcher } from '../../src/rollup/types';
import { bold, cyan, green, underline } from '../../src/utils/colors';
Expand Down Expand Up @@ -146,7 +146,7 @@ export async function watch(command: Record<string, any>): Promise<void> {
});
}

async function close(code: number | null): Promise<void> {
async function close(code: number | null | undefined): Promise<void> {
process.removeListener('uncaughtException', close);
// removing a non-existent listener is a no-op
process.stdin.removeListener('end', close);
Expand Down
18 changes: 2 additions & 16 deletions docs/.vitepress/config.ts
@@ -1,7 +1,7 @@
import alias from '@rollup/plugin-alias';
import { defineConfig } from 'vitepress';
import { moduleAliases } from '../../build-plugins/aliases';
import { resolutions } from '../../build-plugins/replace-browser-modules';
import replaceBrowserModules from '../../build-plugins/replace-browser-modules';
import '../declarations.d';
import { examplesPlugin } from './create-examples';
import { renderMermaidGraphsPlugin } from './mermaid';
Expand Down Expand Up @@ -135,21 +135,7 @@ export default defineConfig({
vite: {
plugins: [
renderMermaidGraphsPlugin(),
{
apply: 'serve',
enforce: 'pre',
name: 'replace-browser-modules',
resolveId(source, importer) {
if (importer && source.startsWith('/@fs')) {
return resolutions.get(source.slice(4));
}
},
transformIndexHtml(html) {
// Unfortunately, picomatch sneaks as a dedendency into the dev bundle.
// This fixes an error.
return html.replace('</head>', '<script>window.process={}</script></head>');
}
},
replaceBrowserModules(),
{
apply: 'build',
enforce: 'pre',
Expand Down
14 changes: 7 additions & 7 deletions docs/repl/stores/options.ts
Expand Up @@ -136,7 +136,7 @@ export const useOptions = defineStore('options2', () => {
name: 'output.amd.define'
});
const optionOutputAmdForceJsExtensionForImports = getBoolean({
available: () => isAmdFormat.value && outputHasMultipleChunks.value,
available: isAmdFormat,
name: 'output.amd.forceJsExtensionForImports'
});
const optionOutputAmdId = getString({
Expand All @@ -149,7 +149,7 @@ export const useOptions = defineStore('options2', () => {
name: 'output.banner'
});
const optionOutputChunkFileNames = getString({
available: outputHasMultipleChunks,
available: alwaysTrue,
defaultValue: '[name]-[hash].js',
name: 'output.chunkFileNames'
});
Expand All @@ -162,7 +162,7 @@ export const useOptions = defineStore('options2', () => {
name: 'output.dynamicImportInCjs'
});
const optionOutputEntryFileNames = getString({
available: outputHasMultipleChunks,
available: alwaysTrue,
defaultValue: '[name].js',
name: 'output.entryFileNames'
});
Expand Down Expand Up @@ -240,7 +240,7 @@ export const useOptions = defineStore('options2', () => {
required: () => true
});
const optionOutputHoistTransitiveImports = getBoolean({
available: outputHasMultipleChunks,
available: alwaysTrue,
defaultValue: true,
name: 'output.hoistTransitiveImports'
});
Expand Down Expand Up @@ -279,7 +279,7 @@ export const useOptions = defineStore('options2', () => {
name: 'output.intro'
});
const optionOutputMinifyInternalExports = getBoolean({
available: outputHasMultipleChunks,
available: alwaysTrue,
name: 'output.minifyInternalExports'
});
const optionOutputNoConflict = getBoolean({
Expand Down Expand Up @@ -315,7 +315,7 @@ export const useOptions = defineStore('options2', () => {
name: 'output.sourcemap'
});
const optionOutputSanitizeFileName = getBoolean({
available: outputHasMultipleChunks,
available: alwaysTrue,
defaultValue: true,
name: 'output.sanitizeFileName'
});
Expand All @@ -337,7 +337,7 @@ export const useOptions = defineStore('options2', () => {
name: 'output.validate'
});
const optionPreserveEntrySignatures = getSelect({
available: outputHasMultipleChunks,
available: alwaysTrue,
defaultValue: 'exports-only',
name: 'preserveEntrySignatures',
options: () => ['strict', 'allow-extension', 'exports-only', false]
Expand Down
11 changes: 10 additions & 1 deletion docs/repl/stores/rollupOutput.ts
Expand Up @@ -48,7 +48,7 @@ async function bundle({ rollup: { instance }, modules, options, setOutput }: Bun
if (import.meta.env.PROD) {
console.clear();
}
console.log(`running Rollup version %c${instance.VERSION}`, 'font-weight: bold');
console.group(`running Rollup version ${instance.VERSION}`);

const modulesById = new Map<string, Module>();
for (const module of modules) {
Expand Down Expand Up @@ -96,20 +96,29 @@ async function bundle({ rollup: { instance }, modules, options, setOutput }: Bun
]
};

console.log('%coptions:', 'font-weight: bold; color: blue', rollupOptions);
try {
const generated = await (
await instance.rollup(rollupOptions)
).generate((rollupOptions as { output?: OutputOptions }).output || {});
console.log('%coutput:', 'font-weight: bold; color: green', generated.output);
setOutput({
error: null,
externalImports: [...externalImports].sort((a, b) => (a < b ? -1 : 1)),
output: generated.output,
warnings
});
} catch (error) {
console.log(
'%cerror:',
'font-weight: bold; color: red',
error,
JSON.parse(JSON.stringify(error))
);
setOutput({ error: error as Error, externalImports: [], output: [], warnings });
logWarning(error as Error);
}
console.groupEnd();
}

export const useRollupOutput = defineStore('rollupOutput', () => {
Expand Down

0 comments on commit fceb680

Please sign in to comment.