Skip to content

Commit 63823fe

Browse files
committed
fixed problems with previous solution
1 parent 9423719 commit 63823fe

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

src/parser/script.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ function scriptParser(scriptObject: ScriptObjectType, defaults: Object, type: st
6363
const cachedBabelScript = Cache.get(cacheKey);
6464
if (cachedBabelScript) {
6565
const finalScript = dataMerge(cachedBabelScript, defaults, type);
66-
const finalObject = {
67-
script: finalScript,
68-
style: cachedBabelScript.style
69-
};
70-
resolve(finalObject);
66+
resolve(finalScript);
7167
} else {
7268
const babelScript = babel.transform(scriptObject.content, options);
7369
// const filename = path.join(defaults.rootPath, '/', defaults.component);
@@ -76,16 +72,12 @@ function scriptParser(scriptObject: ScriptObjectType, defaults: Object, type: st
7672
defaults: defaults
7773
};
7874
Utils.requireFromString(babelScript.code, defaults.component, requireFromStringOptions, Cache)
79-
.then(requiredObject => {
75+
.then(scriptFromString => {
8076
// set the cache for the babel script string
81-
Cache.set(cacheKey, requiredObject);
77+
Cache.set(cacheKey, scriptFromString);
8278

83-
const finalScript = dataMerge(requiredObject.code, defaults, type);
84-
const finalObject = {
85-
script: finalScript,
86-
style: requiredObject.style
87-
};
88-
resolve(finalObject);
79+
const finalScript = dataMerge(scriptFromString, defaults, type);
80+
resolve(finalScript);
8981
})
9082
.catch(error => reject(error));
9183
}

src/utils/require.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ function replaceRelativePaths(code: string, rootPath: string): string {
7878
function requireFromString(code: string, filename: string = '', optsObj: Object = {}, Cache: Object): Promise < Object > {
7979
return new Promise((resolve, reject) => {
8080
const options = new Options(optsObj);
81-
let style = '';
8281
let promiseArray = [];
8382

8483
if (typeof code !== 'string') {
@@ -126,11 +125,7 @@ function requireFromString(code: string, filename: string = '', optsObj: Object
126125
});
127126
} else {
128127
m._compile(code, filename);
129-
const resolvedObject = {
130-
code: m.exports.default,
131-
style: style
132-
};
133-
resolve(resolvedObject);
128+
resolve(m.exports.default);
134129
}
135130
});
136131
}

0 commit comments

Comments
 (0)