diff --git a/packages/compat/src/compat-app-builder.ts b/packages/compat/src/compat-app-builder.ts index 443db410b..fc8b9de2e 100644 --- a/packages/compat/src/compat-app-builder.ts +++ b/packages/compat/src/compat-app-builder.ts @@ -4,7 +4,6 @@ import { explicitRelative, extensionsPattern, warn, - jsHandlebarsCompile, templateColocationPluginPath, cacheBustingPluginVersion, cacheBustingPluginPath, @@ -581,11 +580,6 @@ export class CompatAppBuilder { `module.exports = ${JSON.stringify(pconfig.config, null, 2)}`, 'utf8' ); - writeFileSync( - join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_filter_.js'), - babelFilterTemplate({ skipBabel: this.options.skipBabel, appRoot: this.origAppPackage.root }), - 'utf8' - ); } private addResolverConfig(config: CompatResolverOptions) { @@ -656,11 +650,6 @@ function defaultAddonPackageRules(): PackageRules[] { .reduce((a, b) => a.concat(b), []); } -const babelFilterTemplate = jsHandlebarsCompile(` -const { babelFilter } = require(${JSON.stringify(require.resolve('@embroider/core'))}); -module.exports = babelFilter({{json-stringify skipBabel}}, "{{js-string-escape appRoot}}"); -`) as (params: { skipBabel: Options['skipBabel']; appRoot: string }) => string; - function combinePackageJSON(...layers: object[]) { function custom(objValue: any, srcValue: any, key: string, _object: any, _source: any, stack: { size: number }) { if (key === 'keywords' && stack.size === 0) { diff --git a/packages/core/src/options.ts b/packages/core/src/options.ts index b89b5672f..d957c6b26 100644 --- a/packages/core/src/options.ts +++ b/packages/core/src/options.ts @@ -59,14 +59,6 @@ export default interface Options { // route templates, and controllers which are governed by splitAtRoutes). staticAppPaths?: string[]; - // By default, all modules that get imported into the app go through Babel, so - // that all code will conform with your Babel targets. This option allows you - // to turn Babel off for a particular package. You might need this to work - // around a transpiler bug or you might use this as a build-performance - // optimization if you've manually verified that a particular package doesn't - // need transpilation to be safe in your target browsers. - skipBabel?: { package: string; semverRange?: string }[]; - // This is a performance optimization that can help you avoid the "Your build // is slower because some babel plugins are non-serializable" penalty. If you // provide the locations of known non-serializable objects, we can discover @@ -131,7 +123,6 @@ export function optionsWithDefaults(options?: Options): Required { staticComponents: false, splitAtRoutes: [], staticAppPaths: [], - skipBabel: [], pluginHints: [], amdCompatibility: 'cjs' as const, }; diff --git a/packages/shared-internals/src/babel-filter.ts b/packages/shared-internals/src/babel-filter.ts deleted file mode 100644 index 96cebe448..000000000 --- a/packages/shared-internals/src/babel-filter.ts +++ /dev/null @@ -1,34 +0,0 @@ -import PackageCache from './package-cache'; -import semver from 'semver'; - -export default function babelFilter(skipBabel: { package: string; semverRange?: string }[], appRoot: string) { - return function shouldTranspileFile(filename: string) { - if (!babelCanHandle(filename)) { - // quick exit for non JS extensions - return false; - } - - let owner = PackageCache.shared('embroider', appRoot).ownerOfFile(filename); - if (owner) { - for (let { package: pkg, semverRange } of skipBabel) { - if (owner.name === pkg && (semverRange == null || semver.satisfies(owner.version, semverRange))) { - if (owner.isEmberAddon()) { - throw new Error( - `You can't use skipBabel to disable transpilation of Ember addons, it only works for non-Ember third-party packages` - ); - } - return false; - } - } - } - return true; - }; -} - -function babelCanHandle(filename: string) { - // we can handle .mjs, .js and .ts files with babel. If typescript is enabled, - // .ts files become resolvable and stage3 will be asking us if they should get - // transpiled and the answer is yes. If typescript is not enbled, they will - // not be resolvable, so stage3 won't ask us about them. - return /\.m?[jt]s$/i.test(filename); -} diff --git a/packages/shared-internals/src/index.ts b/packages/shared-internals/src/index.ts index 47a8ea4cf..bd88319a7 100644 --- a/packages/shared-internals/src/index.ts +++ b/packages/shared-internals/src/index.ts @@ -12,7 +12,6 @@ export { default as Package, V2AddonPackage as AddonPackage, V2AppPackage as App export { default as PackageCache } from './package-cache'; export type { RewrittenPackageIndex } from './rewritten-package-cache'; export { RewrittenPackageCache } from './rewritten-package-cache'; -export { default as babelFilter } from './babel-filter'; export { default as packageName } from './package-name'; export { default as tmpdir } from './tmpdir'; export * from './ember-cli-models'; diff --git a/test-packages/support/transpiler.ts b/test-packages/support/transpiler.ts index f1cbef381..3a954d6da 100644 --- a/test-packages/support/transpiler.ts +++ b/test-packages/support/transpiler.ts @@ -6,7 +6,6 @@ import type { BoundExpectFile } from './file-assertions'; import type { AppMeta } from '../../packages/core/src/index'; import { hbsToJS, locateEmbroiderWorkingDir, RewrittenPackageCache } from '../../packages/core/src/index'; import { Memoize } from 'typescript-memoize'; -import { getRewrittenLocation } from './rewritten-path'; export class Transpiler { private appOutputPath: string; @@ -14,7 +13,6 @@ export class Transpiler { let packageCache = RewrittenPackageCache.shared('embroider', appDir); this.appOutputPath = packageCache.maybeMoved(packageCache.get(appDir)).root; this.transpile = this.transpile.bind(this); - this.shouldTranspile = this.shouldTranspile.bind(this); } transpile(contents: string, fileAssert: BoundExpectFile): string { @@ -33,15 +31,6 @@ export class Transpiler { } } - shouldTranspile(relativePath: string) { - // Depending on how the app builds, the babel filter is not at the same location - let embroiderLocation = join(locateEmbroiderWorkingDir(this.appDir), '_babel_filter_.js'); - let shouldTranspile = existsSync(embroiderLocation) - ? require(embroiderLocation) - : require(join(this.appOutputPath, '_babel_filter_')); - return shouldTranspile(join(this.appDir, getRewrittenLocation(this.appDir, relativePath))) as boolean; - } - @Memoize() private get pkgJSON() { return readJSONSync(join(this.appOutputPath, 'package.json')); diff --git a/tests/addon-template/ember-cli-build.js b/tests/addon-template/ember-cli-build.js index e211c6334..a778499b7 100644 --- a/tests/addon-template/ember-cli-build.js +++ b/tests/addon-template/ember-cli-build.js @@ -15,11 +15,5 @@ module.exports = function (defaults) { */ const { maybeEmbroider } = require('@embroider/test-setup'); - return maybeEmbroider(app, { - skipBabel: [ - { - package: 'qunit', - }, - ], - }); + return maybeEmbroider(app); }; diff --git a/tests/app-template/ember-cli-build.js b/tests/app-template/ember-cli-build.js index ab01aed3e..ebb76e53a 100644 --- a/tests/app-template/ember-cli-build.js +++ b/tests/app-template/ember-cli-build.js @@ -6,11 +6,5 @@ const { maybeEmbroider } = require('@embroider/test-setup'); module.exports = function (defaults) { let app = new EmberApp(defaults, {}); - return maybeEmbroider(app, { - skipBabel: [ - { - package: 'qunit', - }, - ], - }); + return maybeEmbroider(app); }; diff --git a/tests/fixtures/blacklisted-addon-build-options/ember-cli-build.js b/tests/fixtures/blacklisted-addon-build-options/ember-cli-build.js index bb4421fac..fad75c7a9 100644 --- a/tests/fixtures/blacklisted-addon-build-options/ember-cli-build.js +++ b/tests/fixtures/blacklisted-addon-build-options/ember-cli-build.js @@ -10,12 +10,5 @@ module.exports = function (defaults) { }, }); - return maybeEmbroider(app, { - - skipBabel: [ - { - package: 'qunit', - }, - ], - }); + return maybeEmbroider(app); }; diff --git a/tests/fixtures/macro-sample-addon/ember-cli-build.js b/tests/fixtures/macro-sample-addon/ember-cli-build.js index 90518ee15..1fa2835f4 100644 --- a/tests/fixtures/macro-sample-addon/ember-cli-build.js +++ b/tests/fixtures/macro-sample-addon/ember-cli-build.js @@ -17,10 +17,5 @@ module.exports = function(defaults) { return maybeEmbroider(app, { useAddonAppBoot: false, - skipBabel: [ - { - package: 'qunit', - }, - ], }); }; diff --git a/tests/scenarios/compat-addon-classic-features-test.ts b/tests/scenarios/compat-addon-classic-features-test.ts index 3f5ebbd58..63ebf4403 100644 --- a/tests/scenarios/compat-addon-classic-features-test.ts +++ b/tests/scenarios/compat-addon-classic-features-test.ts @@ -52,11 +52,6 @@ appScenarios return maybeEmbroider(app, { availableContentForTypes: ['custom'], - skipBabel: [ - { - package: 'qunit', - }, - ], }); }; `, diff --git a/tests/scenarios/compat-exclude-dot-files-test.ts b/tests/scenarios/compat-exclude-dot-files-test.ts index 0e6756640..2544d8ccc 100644 --- a/tests/scenarios/compat-exclude-dot-files-test.ts +++ b/tests/scenarios/compat-exclude-dot-files-test.ts @@ -23,11 +23,6 @@ appScenarios return maybeEmbroider(app, { staticAddonTrees: false, - skipBabel: [ - { - package: 'qunit', - }, - ], }); }; `, diff --git a/tests/scenarios/compat-plugin-hints-test.ts b/tests/scenarios/compat-plugin-hints-test.ts index 503a533de..f57b94794 100644 --- a/tests/scenarios/compat-plugin-hints-test.ts +++ b/tests/scenarios/compat-plugin-hints-test.ts @@ -31,11 +31,6 @@ appScenarios }); return maybeEmbroider(app, { - skipBabel: [ - { - package: 'qunit', - }, - ], pluginHints: [ { resolve: ["${__filename.replace(/\\/g, '/').replace(/\.ts$/, '.js')}"], diff --git a/tests/scenarios/compat-renaming-test.ts b/tests/scenarios/compat-renaming-test.ts index 3e8dfb0d2..0b3da9c8a 100644 --- a/tests/scenarios/compat-renaming-test.ts +++ b/tests/scenarios/compat-renaming-test.ts @@ -24,11 +24,6 @@ appScenarios return maybeEmbroider(app, { staticAddonTrees: false, staticComponents: false, - skipBabel: [ - { - package: 'qunit', - }, - ], // TODO remove this when we virtualise the entrypoint amdCompatibility: { es: [ diff --git a/tests/scenarios/compat-resolver-test.ts b/tests/scenarios/compat-resolver-test.ts index 33504039d..f13639f8d 100644 --- a/tests/scenarios/compat-resolver-test.ts +++ b/tests/scenarios/compat-resolver-test.ts @@ -120,9 +120,6 @@ Scenarios.fromProject(() => new Project()) [require.resolve('@embroider/compat/src/babel-plugin-adjust-imports'), { appRoot: app.dir }], ])} }`, - 'node_modules/.embroider/_babel_filter.js': ` - module.exports = function(filename) { return true } - `, 'node_modules/.embroider/resolver.json': JSON.stringify(resolverOptions), }); }; diff --git a/tests/scenarios/compat-stage2-test.ts b/tests/scenarios/compat-stage2-test.ts index 8f079fa41..7a727eec4 100644 --- a/tests/scenarios/compat-stage2-test.ts +++ b/tests/scenarios/compat-stage2-test.ts @@ -331,19 +331,6 @@ stage2Scenarios amdCompatibility: { es: [['not-a-resolvable-package', ['default']]], }, - skipBabel: [ - { - package: 'babel-filter-test1', - }, - { - package: 'babel-filter-test2', - semverRange: '^4.0.0', - }, - { - package: 'babel-filter-test3', - semverRange: '^2.0.0', - }, - ], staticAppPaths: ['static-dir', 'top-level-static.js'], packageRules: [ { @@ -404,11 +391,6 @@ stage2Scenarios }); return prebuild(app, { - skipBabel: [ - { - package: 'qunit', - }, - ], ...opts }); }; @@ -780,26 +762,6 @@ stage2Scenarios assertFile.matches(/return require\(['"]some-package['"]\)/, 'should find plain cjs require'); }); - test('transpilation runs for ember addons', async function (assert) { - assert.ok(build.shouldTranspile('node_modules/my-addon/components/has-relative-template.js')); - }); - - test('transpilation is skipped when package matches skipBabel', async function (assert) { - assert.ok(!build.shouldTranspile('node_modules/babel-filter-test1/index.js')); - }); - - test('transpilation is skipped when package and version match skipBabel', async function (assert) { - assert.ok(!build.shouldTranspile('node_modules/babel-filter-test2/index.js')); - }); - - test('transpilation runs when package version does not match skipBabel', async function (assert) { - assert.ok(build.shouldTranspile('node_modules/babel-filter-test3/index.js')); - }); - - test('transpilation runs for non-ember package that is not explicitly skipped', async function (assert) { - assert.ok(build.shouldTranspile('node_modules/babel-filter-test4/index.js')); - }); - test(`app's babel plugins ran`, async function () { let assertFile = expectFile('custom-babel-needed.js').transform(build.transpile); assertFile.matches(/console\.log\(['"]embroider-sample-transforms-result['"]\)/); diff --git a/tests/scenarios/core-resolver-test.ts b/tests/scenarios/core-resolver-test.ts index 0f1eba66d..0b3020d7f 100644 --- a/tests/scenarios/core-resolver-test.ts +++ b/tests/scenarios/core-resolver-test.ts @@ -142,9 +142,6 @@ Scenarios.fromProject(() => new Project()) plugins: [] } `, - 'node_modules/.embroider/_babel_filter.js': ` - module.exports = function(filename) { return true } - `, 'node_modules/.embroider/resolver.json': JSON.stringify(resolverOptions), 'node_modules/my-addon/package.json': addonPackageJSON('my-addon', opts?.addonMeta), }); diff --git a/tests/scenarios/router-test.ts b/tests/scenarios/router-test.ts index 4e50cdbce..b53d5f2d4 100644 --- a/tests/scenarios/router-test.ts +++ b/tests/scenarios/router-test.ts @@ -38,11 +38,6 @@ function setupScenario(project: Project) { staticHelpers: true, staticModifiers: true, splitAtRoutes: ['split-me'], - skipBabel: [ - { - package: 'qunit', - }, - ], }); }; `, diff --git a/tests/scenarios/stage1-test.ts b/tests/scenarios/stage1-test.ts index 62a319d61..b88cf124a 100644 --- a/tests/scenarios/stage1-test.ts +++ b/tests/scenarios/stage1-test.ts @@ -30,11 +30,6 @@ appScenarios staticComponents: false, staticHelpers: false, staticModifiers: false, - skipBabel: [ - { - package: 'qunit', - }, - ], }); }; `, diff --git a/tests/scenarios/static-app-test.ts b/tests/scenarios/static-app-test.ts index 435869b61..e074480e2 100644 --- a/tests/scenarios/static-app-test.ts +++ b/tests/scenarios/static-app-test.ts @@ -396,10 +396,6 @@ appScenarios }, }, ], - skipBabel: [ - { package: 'qunit' }, - { package: 'macro-decorators' }, - ], }); }; `, diff --git a/tests/ts-app-template-classic/ember-cli-build.js b/tests/ts-app-template-classic/ember-cli-build.js index 736cf11f1..f46ba13b7 100644 --- a/tests/ts-app-template-classic/ember-cli-build.js +++ b/tests/ts-app-template-classic/ember-cli-build.js @@ -8,11 +8,5 @@ module.exports = function (defaults) { 'ember-cli-babel': { enableTypeScriptTransform: true }, }); - return maybeEmbroider(app, { - skipBabel: [ - { - package: 'qunit', - }, - ], - }); + return maybeEmbroider(app); }; diff --git a/tests/ts-app-template/ember-cli-build.js b/tests/ts-app-template/ember-cli-build.js index 736cf11f1..f46ba13b7 100644 --- a/tests/ts-app-template/ember-cli-build.js +++ b/tests/ts-app-template/ember-cli-build.js @@ -8,11 +8,5 @@ module.exports = function (defaults) { 'ember-cli-babel': { enableTypeScriptTransform: true }, }); - return maybeEmbroider(app, { - skipBabel: [ - { - package: 'qunit', - }, - ], - }); + return maybeEmbroider(app); };