In a wavelength-division multiplexer/demultiplexer, which may be of the free-space kind, which uses a diffraction grating or other such angularly-dispersive element, a substantially flat spectral response is obtained by spatially-shaping the light beam(s) to modify the passband response in the dispersion plane. The spatial shaping may be obtained by means of a plurality of microlenses disposed adjacent a plurality of ports through which pass a corresponding plurality of angularly-dispersed light beams having different centre frequencies/wavelengths. Each microlens may be a cylindrical lens arranged with its cylindrical axis normal to the dispersion plane so as to shape the light beam in only one direction, i.e. that of the dispersion plane. The spatial shaping may be obtained by means of a single lens, conveniently a microlens, disposed adjacent a WDM port through which the wavelength division multiplexed light beam passes. Alternatively, a plurality of microlenses may be provided adjacent the plurality of ports and a single microlens may then be provided adjacent the single WDM port. The plurality of microlenses and the single microlens cooperate to provide a very small loss multiplexer/demultiplexer with a broad gaussian-type spectral response. The diffraction grating may be reflective or transmissive and may be a concave one so as to combine the functions of a grating and a lens. The microlenses could be spherical lenses, diffractive-type elements, and so on. Other dispersive elements, such as prisms, etc., may be used instead of the diffraction grating. By reversing the light ray direction, the demultiplexer can act as a multiplexer. One-dimensional spatial-shaping may be implemented in waveguide WDM devices.