@morgul/snowpack-plugin-vue2
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -25,10 +25,12 @@ // --------------------------------------------------------------------------------------------------------------------- | ||
// Remove the obnoxious comment newlines in the generated code | ||
descriptor.script.content = descriptor.script.content.replace(/\/\/\n/g, ''); | ||
if(descriptor.script) { | ||
// Remove the obnoxious comment newlines in the generated code | ||
descriptor.script.content = descriptor.script.content.replace(/\/\/\n/g, ''); | ||
// Support using `Vue.extends()`. Code adapted from: | ||
// https://github.com/vuejs/vue-loader/blob/master/lib/runtime/componentNormalizer.js#L17-L20 | ||
descriptor.script.content = descriptor.script.content.replace('export default ', 'var scriptExports = '); | ||
descriptor.script.content += ';\nvar options = typeof scriptExports === \'function\' ? scriptExports.options : scriptExports;\n'; | ||
descriptor.script.content += 'export default options;' | ||
// Support using `Vue.extends()`. Code adapted from: | ||
// https://github.com/vuejs/vue-loader/blob/master/lib/runtime/componentNormalizer.js#L17-L20 | ||
descriptor.script.content = descriptor.script.content.replace('export default ', 'var scriptExports = '); | ||
descriptor.script.content += '\nvar options = typeof scriptExports === \'function\' ? scriptExports.options : scriptExports;'; | ||
descriptor.script.content += '\nexport default options;' | ||
} | ||
@@ -49,3 +51,4 @@ return { | ||
// far as hacks go, this isn't the worst. | ||
if(options?.compilerOptions?.scopeId) | ||
const scopeId = options?.compilerOptions?.scopeId; | ||
if(scopeId) | ||
{ | ||
@@ -62,2 +65,6 @@ options.scoped = true; | ||
if(scopeId) { | ||
results.code += `\ndefaultExport._scopeId = "${scopeId}";`; | ||
} | ||
// TODO: Make sure the results are actually compatible. They look really close, but it's hard to say | ||
@@ -64,0 +71,0 @@ return { ...results }; |
{ | ||
"name": "@morgul/snowpack-plugin-vue2", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A snowpack vue2 compiler based on `@snowpack/plugin-vue`.", | ||
@@ -5,0 +5,0 @@ "main": "plugin/plugin.js", |
@@ -58,2 +58,3 @@ const path = require('path'); | ||
expect(resultContent['.css'].code).toMatch(/h1\[data-v-.*\]/); | ||
expect(resultContent['.js'].code).toMatch(/"data-v-.*"/); | ||
}); |
@@ -44,2 +44,4 @@ # Snowpack Vue 2 Plugin | ||
_Note: As more development has happened, it's become clear that [@vue/component-compiler-utils][compiler-utils] doesn't do everything that [@vue/compiler-sfc][compiler-sfc], instead relying on [vue-loader][] to do some of it. That's fine, we can slowly intriduce [vue-loader][] code as needed to handle these edge cases._ | ||
### Project Guidelines | ||
@@ -46,0 +48,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41068
437
66