@@ -50,9 +50,9 @@ export default function myPlugin(options = {}) {
5050 return {
5151 resolveId (code , id ) {
5252 // only adds an extension if there isn't one already
53- id = addExtension (id); // `foo` -> `foo.js`, `foo.js -> foo.js`
54- id = addExtension (id, ' .myext' ); // `foo` -> `foo.myext`, `foo.js -> `foo.js`
55- }
53+ id = addExtension (id); // `foo` -> `foo.js`, `foo.js` -> ` foo.js`
54+ id = addExtension (id, ' .myext' ); // `foo` -> `foo.myext`, `foo.js` -> `foo.js`
55+ },
5656 };
5757}
5858```
@@ -88,9 +88,9 @@ export default function myPlugin(options = {}) {
8888 },
8989 leave (node ) {
9090 if (node .scope ) scope = scope .parent ;
91- }
91+ },
9292 });
93- }
93+ },
9494 };
9595}
9696```
@@ -126,15 +126,15 @@ import { createFilter } from '@rollup/pluginutils';
126126export default function myPlugin (options = {}) {
127127 // assume that the myPlugin accepts options of `options.include` and `options.exclude`
128128 var filter = createFilter (options .include , options .exclude , {
129- resolve: ' /my/base/dir'
129+ resolve: ' /my/base/dir' ,
130130 });
131131
132132 return {
133133 transform (code , id ) {
134134 if (! filter (id)) return ;
135135
136136 // proceed with the transformation...
137- }
137+ },
138138 };
139139}
140140```
@@ -160,14 +160,14 @@ import { dataToEsm } from '@rollup/pluginutils';
160160const esModuleSource = dataToEsm (
161161 {
162162 custom: ' data' ,
163- to: [' treeshake' ]
163+ to: [' treeshake' ],
164164 },
165165 {
166166 compact: false ,
167167 indent: ' \t ' ,
168168 preferConst: false ,
169169 objectShorthand: false ,
170- namedExports: true
170+ namedExports: true ,
171171 }
172172);
173173/*
@@ -207,11 +207,11 @@ export default function myPlugin(options = {}) {
207207 if (node .type === ' VariableDeclarator' ) {
208208 const declaredNames = extractAssignedNames (node .id );
209209 // do something with the declared names
210- // e.g. for `const {x, y: z} = ... => declaredNames = ['x', 'z']
210+ // e.g. for `const {x, y: z} = ...` => declaredNames = ['x', 'z']
211211 }
212- }
212+ },
213213 });
214- }
214+ },
215215 };
216216}
217217```
@@ -232,6 +232,22 @@ makeLegalIdentifier('foo-bar'); // 'foo_bar'
232232makeLegalIdentifier (' typeof' ); // '_typeof'
233233```
234234
235+ ### normalizePath
236+
237+ Converts path separators to forward slash.
238+
239+ Parameters: ` (filename: String) ` <br >
240+ Returns: ` String `
241+
242+ #### Usage
243+
244+ ``` js
245+ import { normalizePath } from ' @rollup/pluginutils' ;
246+
247+ normalizePath (' foo\\ bar' ); // 'foo/bar'
248+ normalizePath (' foo/bar' ); // 'foo/bar'
249+ ```
250+
235251## Meta
236252
237253[ CONTRIBUTING] ( /.github/CONTRIBUTING.md )
0 commit comments