Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fully specify resolve path with .js extension #322

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('generateProxies', () => {
`/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';
import { createReactComponent } from './react-component-lib/index.js';

import type { JSX } from 'component-library';

Expand All @@ -77,7 +77,7 @@ applyPolyfills().then(() => defineCustomElements());
`/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';
import { createReactComponent } from './react-component-lib/index.js';

import type { JSX } from 'component-library';

Expand All @@ -102,7 +102,7 @@ defineCustomElements();
`/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';
import { createReactComponent } from './react-component-lib/index.js';

import type { JSX } from 'component-library';

Expand All @@ -125,7 +125,7 @@ import type { JSX } from 'component-library';
`/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';
import { createReactComponent } from './react-component-lib/index.js';

import type { JSX } from 'component-library/components';

Expand All @@ -149,7 +149,7 @@ import type { JSX } from 'component-library/components';
`/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';
import { createReactComponent } from './react-component-lib/index.js';

import type { JSX } from 'component-library/custom-dir/hello';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { createElement } from 'react';

import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils/index.js';

export interface HTMLStencilElement extends HTMLElement {
componentOnReady(): Promise<this>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';

import { OverlayEventDetail } from './interfaces';
import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils/index.js';

interface OverlayElement extends HTMLElement {
present: () => Promise<void>;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-output-target/react-component-lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { createReactComponent } from './createComponent';
export { createOverlayComponent } from './createOverlayComponent';
export { createReactComponent } from './createComponent.js';
export { createOverlayComponent } from './createOverlayComponent.js';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { camelToDashCase } from './case';
import { camelToDashCase } from './case.js';

export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => {
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ export const defineCustomElement = (tagName: string, customElement: any) => {
}
};

export * from './attachProps';
export * from './case';
export * from './attachProps.js';
export * from './case.js';
2 changes: 1 addition & 1 deletion packages/react-output-target/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { reactOutputTarget } from './plugin';
export { reactOutputTarget } from './plugin.js';
export type { OutputTargetReact } from './types';
4 changes: 2 additions & 2 deletions packages/react-output-target/src/output-react.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import type { OutputTargetReact, PackageJSON } from './types';
import { dashToPascalCase, normalizePath, readPackageJson, relativeImport, sortBy } from './utils';
import { dashToPascalCase, normalizePath, readPackageJson, relativeImport, sortBy } from './utils.js';
import type { CompilerCtx, ComponentCompilerMeta, Config, CopyResults, OutputTargetDist } from '@stencil/core/internal';

/**
Expand Down Expand Up @@ -62,7 +62,7 @@ export function generateProxies(
const imports = `/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';\n`;
import { createReactComponent } from './react-component-lib/index.js';\n`;

/**
* Generate JSX import type from correct location.
Expand Down
4 changes: 2 additions & 2 deletions packages/react-output-target/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Config, OutputTargetCustom } from '@stencil/core/internal';
import { normalizePath } from './utils';
import { normalizePath } from './utils.js';
import type { OutputTargetReact } from './types';
import { reactProxyOutput } from './output-react';
import { reactProxyOutput } from './output-react.js';
import path from 'path';

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/vue-output-target/__tests__/output-vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('generateProxies', () => {
`/* eslint-disable */
/* tslint:disable */
/* auto-generated vue proxies */
import { defineContainer } from './vue-component-lib/utils';
import { defineContainer } from './vue-component-lib/utils.js';

import type { JSX } from 'component-library';

Expand All @@ -48,7 +48,7 @@ applyPolyfills().then(() => defineCustomElements());
`/* eslint-disable */
/* tslint:disable */
/* auto-generated vue proxies */
import { defineContainer } from './vue-component-lib/utils';
import { defineContainer } from './vue-component-lib/utils.js';

import type { JSX } from 'component-library';

Expand All @@ -73,7 +73,7 @@ defineCustomElements();
`/* eslint-disable */
/* tslint:disable */
/* auto-generated vue proxies */
import { defineContainer } from './vue-component-lib/utils';
import { defineContainer } from './vue-component-lib/utils.js';

import type { JSX } from 'component-library';

Expand All @@ -95,7 +95,7 @@ import type { JSX } from 'component-library';
`/* eslint-disable */
/* tslint:disable */
/* auto-generated vue proxies */
import { defineContainer } from './vue-component-lib/utils';
import { defineContainer } from './vue-component-lib/utils.js';

import type { JSX } from 'component-library/components';

Expand All @@ -118,7 +118,7 @@ import type { JSX } from 'component-library/components';
`/* eslint-disable */
/* tslint:disable */
/* auto-generated vue proxies */
import { defineContainer } from './vue-component-lib/utils';
import { defineContainer } from './vue-component-lib/utils.js';

import type { JSX } from 'component-library/custom-dir/hello';

Expand Down
3 changes: 3 additions & 0 deletions packages/vue-output-target/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"json",
"jsx"
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.[jt]s$": "$1"
},
"testURL": "http://localhost"
},
"gitHead": "a3588e905186a0e86e7f88418fd5b2f9531b55e0",
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-output-target/src/generate-vue-component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dashToPascalCase } from './utils';
import { dashToPascalCase } from './utils.js';
import { ComponentCompilerMeta } from '@stencil/core/internal';
import { ComponentModelConfig } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-output-target/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { vueOutputTarget } from './plugin';
export { vueOutputTarget } from './plugin.js';
export type { OutputTargetVue, ComponentModelConfig } from './types';
8 changes: 4 additions & 4 deletions packages/vue-output-target/src/output-vue.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import type { OutputTargetVue, PackageJSON } from './types';
import type { CompilerCtx, ComponentCompilerMeta, Config, OutputTargetDist } from '@stencil/core/internal';
import { createComponentDefinition } from './generate-vue-component';
import { normalizePath, readPackageJson, relativeImport, sortBy, dashToPascalCase } from './utils';
import { createComponentDefinition } from './generate-vue-component.js';
import { normalizePath, readPackageJson, relativeImport, sortBy, dashToPascalCase } from './utils.js';

export async function vueProxyOutput(
config: Config,
Expand Down Expand Up @@ -40,7 +40,7 @@ export function generateProxies(
const imports = `/* eslint-disable */
/* tslint:disable */
/* auto-generated vue proxies */
import { defineContainer } from './vue-component-lib/utils';\n`;
import { defineContainer } from './vue-component-lib/utils.js';\n`;

const generateTypeImports = () => {
if (outputTarget.componentCorePackage !== undefined) {
Expand All @@ -50,7 +50,7 @@ import { defineContainer } from './vue-component-lib/utils';\n`;
return `import type { ${IMPORT_TYPES} } from '${normalizePath(outputTarget.componentCorePackage)}${dirPath}';\n`;
}

return `import type { ${IMPORT_TYPES} } from '${normalizePath(componentsTypeFile)}';\n`;
return `import type { ${IMPORT_TYPES} } from '${normalizePath(componentsTypeFile)}.js';\n`;
};

const typeImports = generateTypeImports();
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-output-target/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Config, OutputTargetCustom } from '@stencil/core/internal';
import { normalizePath } from './utils';
import { normalizePath } from './utils.js';
import type { OutputTargetVue } from './types';
import { vueProxyOutput } from './output-vue';
import { vueProxyOutput } from './output-vue.js';
import path from 'path';

export const vueOutputTarget = (outputTarget: OutputTargetVue): OutputTargetCustom => ({
Expand Down