diff --git a/package.json b/package.json index b511af88b84..bc55760bbdd 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,9 @@ "name": "@stencil/core", "version": "2.0.0-2", "license": "MIT", - "main": "internal/stencil-core/index.js", - "types": "internal/stencil-core/index.d.ts", + "main": "./internal/stencil-core/index.cjs", + "module": "./internal/stencil-core/index.js", + "types": "./internal/stencil-core/index.d.ts", "bin": { "stencil": "bin/stencil" }, @@ -137,5 +138,6 @@ "custom elements", "pwa", "progressive web app" - ] -} + ], + "dependencies": {} +} \ No newline at end of file diff --git a/scripts/bundles/internal.ts b/scripts/bundles/internal.ts index b5e2188fc3d..7bbc0f143d9 100644 --- a/scripts/bundles/internal.ts +++ b/scripts/bundles/internal.ts @@ -1,5 +1,5 @@ import fs from 'fs-extra'; -import { BuildOptions } from '../utils/options'; +import type { BuildOptions } from '../utils/options'; import { cleanDts } from '../utils/bundle-dts'; import { internalAppData } from './interal-app-data'; import { internalClient } from './internal-platform-client'; @@ -15,7 +15,7 @@ export async function internal(opts: BuildOptions) { await copyStencilInternalDts(opts, opts.output.internalDir); - await createStencilCoreEntry(opts.output.internalDir); + await copyStencilCoreEntry(opts); // copy @stencil/core/internal default entry, which defaults to client // but we're not exposing all of Stencil's internal code (only the types) @@ -72,14 +72,6 @@ async function copyStencilInternalDts(opts: BuildOptions, outputInternalDir: str const runtimeDts = cleanDts(await fs.readFile(runtimeDtsSrcPath, 'utf8')); await fs.writeFile(runtimeDtsDestPath, runtimeDts); - // @stencil/core/internal/stencil-core/index.d.ts file - // actual public dts when importing @stencil/core - const stencilCoreDtsSrc = join(opts.buildDir, 'declarations', 'stencil-core', 'index.d.ts'); - const stencilCoreDstDir = join(outputInternalDir, 'stencil-core'); - const stencilCoreDtsDst = join(stencilCoreDstDir, 'index.d.ts'); - await fs.ensureDir(stencilCoreDstDir); - await fs.copyFile(stencilCoreDtsSrc, stencilCoreDtsDst); - // @stencil/core/internal/stencil-ext-modules.d.ts (.svg/.css) const srcExtModuleOutput = join(opts.srcDir, 'declarations', 'stencil-ext-modules.d.ts'); const dstExtModuleOutput = join(outputInternalDir, 'stencil-ext-modules.d.ts'); @@ -90,9 +82,10 @@ function prependExtModules(content: string) { return `/// \n` + content; } -async function createStencilCoreEntry(outputInternalDir: string) { - // write @stencil/core entry (really only used for node resolving, not its actual code as you can see) - const stencilCoreDstDir = join(outputInternalDir, 'stencil-core'); +async function copyStencilCoreEntry(opts: BuildOptions) { + // write @stencil/core entry + const stencilCoreSrcDir = join(opts.srcDir, 'internal', 'stencil-core'); + const stencilCoreDstDir = join(opts.output.internalDir, 'stencil-core'); await fs.ensureDir(stencilCoreDstDir); - await fs.writeFile(join(stencilCoreDstDir, 'index.js'), `exports.h = function() {};`); + await fs.copy(stencilCoreSrcDir, stencilCoreDstDir); } diff --git a/src/internal/stencil-core/index.cjs b/src/internal/stencil-core/index.cjs new file mode 100644 index 00000000000..a10e1472f5f --- /dev/null +++ b/src/internal/stencil-core/index.cjs @@ -0,0 +1 @@ +exports.h = function () {}; diff --git a/src/declarations/stencil-core/index.ts b/src/internal/stencil-core/index.d.ts similarity index 100% rename from src/declarations/stencil-core/index.ts rename to src/internal/stencil-core/index.d.ts index 429bb076829..a2a4b3a9d91 100644 --- a/src/declarations/stencil-core/index.ts +++ b/src/internal/stencil-core/index.d.ts @@ -10,11 +10,11 @@ export type { EventOptions, FunctionalComponent, FunctionalUtilities, + JSX, MethodOptions, ModeStyles, ListenOptions, ListenTargetOptions, - JSX, PropOptions, QueueApi, RafCallback, @@ -34,12 +34,12 @@ export { forceUpdate, h, Host, - Method, Listen, + Method, Prop, readTask, - setMode, setAssetPath, + setMode, State, Watch, writeTask, diff --git a/src/internal/stencil-core/index.js b/src/internal/stencil-core/index.js new file mode 100644 index 00000000000..15887b391e4 --- /dev/null +++ b/src/internal/stencil-core/index.js @@ -0,0 +1,14 @@ +export { + Build, + getAssetPath, + getElement, + getMode, + getRenderingRef, + forceUpdate, + h, + Host, + readTask, + setMode, + setAssetPath, + writeTask, +} from '../client/index.js'; diff --git a/tsconfig.json b/tsconfig.json index 44e163c8035..b237638ded8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -54,7 +54,6 @@ "src/compiler/index.ts", "src/compiler/public.ts", "src/compiler/sys/modules/index.ts", - "src/declarations/stencil-core/index.ts", "src/dev-server/index.ts", "src/dev-server/public.ts", "src/dev-server/server-worker.ts",