Skip to content

Commit

Permalink
fix(): incorrect import paths on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Schaller authored and Dennis Schaller committed Nov 5, 2019
1 parent 13bf915 commit 53c9111
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
5 changes: 4 additions & 1 deletion packages/angular-output-target/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@
],
"testURL": "http://localhost"
},
"gitHead": "a3588e905186a0e86e7f88418fd5b2f9531b55e0"
"gitHead": "a3588e905186a0e86e7f88418fd5b2f9531b55e0",
"dependencies": {
"slash": "^3.0.0"
}
}
7 changes: 4 additions & 3 deletions packages/angular-output-target/src/generate-proxies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import slash from 'slash';

import { OutputTargetAngular } from './types';
import { GENERATED_DTS, dashToPascalCase, readPackageJson, relativeImport } from './utils';
Expand All @@ -17,8 +18,8 @@ export default async function generateProxies(compilerCtx: CompilerCtx, componen
import { Component, ElementRef, ChangeDetectorRef, EventEmitter } from '@angular/core';`;

const sourceImports = !outputTarget.componentCorePackage ?
`import { Components } from '${componentsTypeFile}';` :
`import { Components } from '${outputTarget.componentCorePackage}'`;
`import { Components } from '${slash(componentsTypeFile)}';` :
`import { Components } from '${slash(outputTarget.componentCorePackage)}'`;

const final: string[] = [
imports,
Expand Down Expand Up @@ -110,7 +111,7 @@ function getProxyUtils(outputTarget: OutputTargetAngular) {
return PROXY_UTILS.replace(/export function/g, 'function');
} else {
const utilsPath = relativeImport(outputTarget.directivesProxyFile, outputTarget.directivesUtilsFile, '.ts');
return `import { proxyInputs, proxyMethods, proxyOutputs } from '${utilsPath}';\n`;
return `import { proxyInputs, proxyMethods, proxyOutputs } from '${slash(utilsPath)}';\n`;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/react-output-target/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,8 @@
],
"testURL": "http://localhost"
},
"gitHead": "a3588e905186a0e86e7f88418fd5b2f9531b55e0"
"gitHead": "a3588e905186a0e86e7f88418fd5b2f9531b55e0",
"dependencies": {
"slash": "^3.0.0"
}
}
19 changes: 12 additions & 7 deletions packages/react-output-target/src/output-react.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import slash from 'slash';
import { OutputTargetReact } from './types';
import { dashToPascalCase, readPackageJson, relativeImport, sortBy } from './utils';
import { CompilerCtx, ComponentCompilerMeta, Config } from '@stencil/core/internal';
Expand Down Expand Up @@ -38,12 +39,14 @@ async function generateProxies(
import { createReactComponent } from './react-component-lib';\n`;

const typeImports = !outputTarget.componentCorePackage
? `import { ${IMPORT_TYPES} } from '${componentsTypeFile}';\n`
: `import { ${IMPORT_TYPES} } from '${outputTarget.componentCorePackage}';\n`;

const sourceImports = `import { ${REGISTER_CUSTOM_ELEMENTS}, ${APPLY_POLYFILLS} } from '${path.join(
outputTarget.componentCorePackage || '',
outputTarget.loaderDir || DEFAULT_LOADER_DIR,
? `import { ${IMPORT_TYPES} } from '${slash(componentsTypeFile)}';\n`
: `import { ${IMPORT_TYPES} } from '${slash(outputTarget.componentCorePackage)}';\n`;

const sourceImports = `import { ${REGISTER_CUSTOM_ELEMENTS}, ${APPLY_POLYFILLS} } from '${slash(
path.join(
outputTarget.componentCorePackage || '',
outputTarget.loaderDir || DEFAULT_LOADER_DIR,
),
)}';\n`;

const registerCustomElements = `${APPLY_POLYFILLS}().then(() => { ${REGISTER_CUSTOM_ELEMENTS}(window); });`;
Expand All @@ -65,7 +68,9 @@ function createComponentDefinition(cmpMeta: ComponentCompilerMeta) {
const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName);

return [
`export const ${tagNameAsPascal} = createReactComponent<${IMPORT_TYPES}.${tagNameAsPascal}, HTML${tagNameAsPascal}Element>('${cmpMeta.tagName}');`,
`export const ${tagNameAsPascal} = createReactComponent<${IMPORT_TYPES}.${tagNameAsPascal}, HTML${tagNameAsPascal}Element>('${
cmpMeta.tagName
}');`,
];
}

Expand Down

0 comments on commit 53c9111

Please sign in to comment.