diff --git a/src/compiler/app/app-global-scripts.ts b/src/compiler/app/app-global-scripts.ts index 91bb4f5625c..07691f232e7 100644 --- a/src/compiler/app/app-global-scripts.ts +++ b/src/compiler/app/app-global-scripts.ts @@ -3,8 +3,8 @@ import { buildExpressionReplacer } from '../build/replacer'; import { createOnWarnFn, loadRollupDiagnostics } from '../../util/logger/logger-rollup'; import { generatePreamble, minifyJs } from '../util'; import { getAppPublicPath, getGlobalDist, getGlobalFileName, getGlobalWWW } from './app-file-naming'; +import inMemoryFsRead from '../bundle/rollup-plugins/in-memory-fs-read'; import { transpileToEs5 } from '../transpile/core-build'; -import transpiledInMemoryPlugin from '../bundle/rollup-plugins/transpiled-in-memory'; export async function generateAppGlobalScript(config: Config, compilerCtx: CompilerCtx, buildCtx: BuildCtx, appRegistry: AppRegistry, sourceTarget?: SourceTarget) { @@ -109,7 +109,7 @@ async function bundleProjectGlobal(config: Config, compilerCtx: CompilerCtx, bui include: 'node_modules/**', sourceMap: false }), - transpiledInMemoryPlugin(config, compilerCtx), + inMemoryFsRead(config, compilerCtx), ...config.plugins ], onwarn: createOnWarnFn(config, buildCtx.diagnostics) diff --git a/src/compiler/bundle/rollup-bundle.ts b/src/compiler/bundle/rollup-bundle.ts index a0ac0b8376c..25dc76415a0 100644 --- a/src/compiler/bundle/rollup-bundle.ts +++ b/src/compiler/bundle/rollup-bundle.ts @@ -1,14 +1,14 @@ import { BuildCtx, CompilerCtx, Config, EntryModule, JSModuleList } from '../../declarations'; +import bundleEntryFile from './rollup-plugins/bundle-entry-file'; +import bundleJson from './rollup-plugins/json'; import { createOnWarnFn, loadRollupDiagnostics } from '../../util/logger/logger-rollup'; import { generatePreamble, hasError } from '../util'; import { getBundleIdPlaceholder } from '../../util/data-serialize'; -import pathsResolution from './rollup-plugins/paths-resolution'; import localResolution from './rollup-plugins/local-resolution'; -import transpiledInMemoryPlugin from './rollup-plugins/transpiled-in-memory'; -import bundleEntryFile from './rollup-plugins/bundle-entry-file'; +import inMemoryFsRead from './rollup-plugins/in-memory-fs-read'; import { InputOptions, OutputChunk, rollup } from 'rollup'; import nodeEnvVars from './rollup-plugins/node-env-vars'; -import bundleJson from './rollup-plugins/json'; +import pathsResolution from './rollup-plugins/paths-resolution'; export async function createBundle(config: Config, compilerCtx: CompilerCtx, buildCtx: BuildCtx, entryModules: EntryModule[]) { @@ -33,7 +33,7 @@ export async function createBundle(config: Config, compilerCtx: CompilerCtx, bui globals(), builtins(), bundleEntryFile(config, entryModules), - transpiledInMemoryPlugin(config, compilerCtx), + inMemoryFsRead(config, compilerCtx), await pathsResolution(config, compilerCtx), localResolution(config, compilerCtx), nodeEnvVars(config), diff --git a/src/compiler/bundle/rollup-plugins/transpiled-in-memory.ts b/src/compiler/bundle/rollup-plugins/in-memory-fs-read.ts similarity index 78% rename from src/compiler/bundle/rollup-plugins/transpiled-in-memory.ts rename to src/compiler/bundle/rollup-plugins/in-memory-fs-read.ts index a27987c2636..9f72c936853 100644 --- a/src/compiler/bundle/rollup-plugins/transpiled-in-memory.ts +++ b/src/compiler/bundle/rollup-plugins/in-memory-fs-read.ts @@ -1,14 +1,15 @@ -import { CompilerCtx, Config, FilesMap } from '../../../util/interfaces'; +import { CompilerCtx, Config, FilesMap } from '../../../declarations'; import { normalizePath } from '../../util'; -export default function transpiledInMemoryPlugin(config: Config, ctx: CompilerCtx) { + +export default function inMemoryFsRead(config: Config, compilerCtx: CompilerCtx) { const sys = config.sys; const assetsCache: FilesMap = {}; return { - name: 'transpiledInMemoryPlugin', + name: 'inMemoryFsRead', - resolveId(importee: string, importer: string): string { + async resolveId(importee: string, importer: string) { if (!sys.path.isAbsolute(importee)) { importee = normalizePath(sys.path.resolve(importer ? sys.path.dirname(importer) : sys.path.resolve(), importee)); @@ -19,15 +20,15 @@ export default function transpiledInMemoryPlugin(config: Config, ctx: CompilerCt // it's possible the importee is a file pointing directly to the source ts file // if it is a ts file path, then we're good to go - var moduleFile = ctx.moduleFiles[importee]; - if (ctx.moduleFiles[importee]) { + var moduleFile = compilerCtx.moduleFiles[importee]; + if (compilerCtx.moduleFiles[importee]) { return moduleFile.jsFilePath; } - const tsFileNames = Object.keys(ctx.moduleFiles); + const tsFileNames = Object.keys(compilerCtx.moduleFiles); for (var i = 0; i < tsFileNames.length; i++) { // see if we can find by importeE - moduleFile = ctx.moduleFiles[tsFileNames[i]]; + moduleFile = compilerCtx.moduleFiles[tsFileNames[i]]; if (moduleFile.jsFilePath === importee) { // awesome, there's a module file for this js file, we're good here return importee; @@ -41,7 +42,7 @@ export default function transpiledInMemoryPlugin(config: Config, ctx: CompilerCt // think slide's swiper dependency for (i = 0; i < tsFileNames.length; i++) { // see if we can find by importeR - moduleFile = ctx.moduleFiles[tsFileNames[i]]; + moduleFile = compilerCtx.moduleFiles[tsFileNames[i]]; if (moduleFile.jsFilePath === importer) { // awesome, there's a module file for this js file via importeR // now let's check if this module has an assets directory @@ -54,7 +55,7 @@ export default function transpiledInMemoryPlugin(config: Config, ctx: CompilerCt // ok, we've got a potential absolute path where the file "could" be try { // let's see if it actually exists, but with readFileSync :( - assetsCache[assetsFilePath] = ctx.fs.readFileSync(assetsFilePath); + assetsCache[assetsFilePath] = compilerCtx.fs.readFileSync(assetsFilePath); if (typeof assetsCache[assetsFilePath] === 'string') { return assetsFilePath; } @@ -77,7 +78,7 @@ export default function transpiledInMemoryPlugin(config: Config, ctx: CompilerCt return assetsCache[sourcePath]; } - return ctx.fs.readFile(sourcePath); + return compilerCtx.fs.readFile(sourcePath); } }; }