File tree 11 files changed +35
-10
lines changed
11 files changed +35
-10
lines changed Original file line number Diff line number Diff line change @@ -123,8 +123,9 @@ export default {
123
123
/** Add a custom language preprocessor */
124
124
potatoLanguage ({ content, filename, attributes }) {
125
125
const { code , map } = require (' potato-language' ).render (content);
126
+ const { src , ... cleanedAttributes } = attributes;
126
127
127
- return { code, map };
128
+ return { code, map, attributes : cleanedAttributes };
128
129
},
129
130
}),
130
131
}),
Original file line number Diff line number Diff line change @@ -67,3 +67,8 @@ export const getTagInfo = async ({
67
67
markup,
68
68
} ;
69
69
} ;
70
+
71
+ export const removeSrcAttribute = ( attributes : Record < string , any > ) => {
72
+ const { src, ...rest } = attributes ;
73
+ return rest ;
74
+ } ;
Original file line number Diff line number Diff line change 1
1
import { concat } from '../modules/utils' ;
2
- import { getTagInfo } from '../modules/tagInfo' ;
2
+ import { getTagInfo , removeSrcAttribute } from '../modules/tagInfo' ;
3
3
import { prepareContent } from '../modules/prepareContent' ;
4
4
5
5
import type { PreprocessorGroup , Options } from '../types' ;
@@ -22,6 +22,7 @@ const babel = (options?: Options.Babel): PreprocessorGroup => ({
22
22
23
23
return {
24
24
...transformed ,
25
+ attributes : removeSrcAttribute ( transformed . attributes || attributes ) ,
25
26
dependencies : concat ( dependencies , transformed . dependencies ) ,
26
27
} ;
27
28
} ,
Original file line number Diff line number Diff line change 1
- import { getTagInfo } from '../modules/tagInfo' ;
1
+ import { getTagInfo , removeSrcAttribute } from '../modules/tagInfo' ;
2
2
import { concat } from '../modules/utils' ;
3
3
import { prepareContent } from '../modules/prepareContent' ;
4
4
@@ -32,6 +32,7 @@ const coffeescript = (options?: Options.Coffeescript): PreprocessorGroup => ({
32
32
33
33
return {
34
34
...transformed ,
35
+ attributes : removeSrcAttribute ( transformed . attributes || attributes ) ,
35
36
dependencies : concat ( dependencies , transformed . dependencies ) ,
36
37
} ;
37
38
} ,
Original file line number Diff line number Diff line change 1
- import { getTagInfo } from '../modules/tagInfo' ;
1
+ import { getTagInfo , removeSrcAttribute } from '../modules/tagInfo' ;
2
2
import { concat } from '../modules/utils' ;
3
3
import { prepareContent } from '../modules/prepareContent' ;
4
4
@@ -25,6 +25,7 @@ const less = (options?: Options.Less): PreprocessorGroup => ({
25
25
26
26
return {
27
27
...transformed ,
28
+ attributes : removeSrcAttribute ( transformed . attributes || attributes ) ,
28
29
dependencies : concat ( dependencies , transformed . dependencies ) ,
29
30
} ;
30
31
} ,
Original file line number Diff line number Diff line change 1
- import { getTagInfo } from '../modules/tagInfo' ;
1
+ import { getTagInfo , removeSrcAttribute } from '../modules/tagInfo' ;
2
2
import { concat } from '../modules/utils' ;
3
3
import { prepareContent } from '../modules/prepareContent' ;
4
4
@@ -23,6 +23,7 @@ const postcss = (options?: Options.Postcss): PreprocessorGroup => ({
23
23
24
24
return {
25
25
...transformed ,
26
+ attributes : removeSrcAttribute ( transformed . attributes || attributes ) ,
26
27
dependencies : concat ( dependencies , transformed . dependencies ) ,
27
28
} ;
28
29
} ,
Original file line number Diff line number Diff line change 1
- import { getTagInfo } from '../modules/tagInfo' ;
1
+ import { getTagInfo , removeSrcAttribute } from '../modules/tagInfo' ;
2
2
import { concat } from '../modules/utils' ;
3
3
import { prepareContent } from '../modules/prepareContent' ;
4
4
@@ -33,6 +33,7 @@ const scss = (options?: Options.Sass): PreprocessorGroup => ({
33
33
34
34
return {
35
35
...transformed ,
36
+ attributes : removeSrcAttribute ( transformed . attributes || attributes ) ,
36
37
dependencies : concat ( dependencies , transformed . dependencies ) ,
37
38
} ;
38
39
} ,
Original file line number Diff line number Diff line change 1
- import { getTagInfo } from '../modules/tagInfo' ;
1
+ import { getTagInfo , removeSrcAttribute } from '../modules/tagInfo' ;
2
2
import { concat } from '../modules/utils' ;
3
3
import { prepareContent } from '../modules/prepareContent' ;
4
4
@@ -31,6 +31,7 @@ const stylus = (options?: Options.Stylus): PreprocessorGroup => ({
31
31
32
32
return {
33
33
...transformed ,
34
+ attributes : removeSrcAttribute ( transformed . attributes || attributes ) ,
34
35
dependencies : concat ( dependencies , transformed . dependencies ) ,
35
36
} ;
36
37
} ,
Original file line number Diff line number Diff line change 1
- import { getTagInfo } from '../modules/tagInfo' ;
1
+ import { getTagInfo , removeSrcAttribute } from '../modules/tagInfo' ;
2
2
import { concat } from '../modules/utils' ;
3
3
import { prepareContent } from '../modules/prepareContent' ;
4
4
@@ -26,6 +26,7 @@ const typescript = (options?: Options.Typescript): PreprocessorGroup => ({
26
26
27
27
return {
28
28
...transformed ,
29
+ attributes : removeSrcAttribute ( transformed . attributes || attributes ) ,
29
30
dependencies : concat ( dependencies , transformed . dependencies ) ,
30
31
} ;
31
32
} ,
Original file line number Diff line number Diff line change @@ -83,7 +83,19 @@ const transformer: Transformer<Options.GlobalStyle> = async ({
83
83
map : options ?. sourceMap ? { prev : map } : false ,
84
84
} ) ;
85
85
86
- return { code : css , map : newMap } ;
86
+ return {
87
+ code : css ,
88
+ map : newMap ,
89
+ attributes :
90
+ attributes &&
91
+ Object . keys ( attributes ) . reduce ( ( acc : any , key ) => {
92
+ if ( key !== 'global' ) {
93
+ acc [ key ] = attributes [ key ] ;
94
+ }
95
+
96
+ return acc ;
97
+ } , { } ) ,
98
+ } ;
87
99
} ;
88
100
89
101
export { transformer } ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ describe(`processor - babel`, () => {
23
23
] ) ;
24
24
25
25
expect ( preprocessed . toString ?.( ) ) . toMatchInlineSnapshot ( `
26
- "<script src="./fixtures/script.babel.js" >export var hello = {};
26
+ "<script>export var hello = {};
27
27
export var world = hello == null ? void 0 : hello.value;</script><div></div>"
28
28
` ) ;
29
29
} ) ;
You can’t perform that action at this time.
0 commit comments