Skip to content

Commit

Permalink
chore(internal): update config based on embroider-build/embroider#1106
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Feb 3, 2022
1 parent 2f513d2 commit 4ae8d86
Show file tree
Hide file tree
Showing 3 changed files with 2,542 additions and 3,335 deletions.
1 change: 1 addition & 0 deletions ember-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"npm-run-all": "4.1.5",
"rollup": "2.66.1",
"rollup-plugin-multi-input": "^1.3.1",
"rollup-plugin-ts": "^2.0.5",
"semantic-release": "^17.0.0",
"typescript": "^4.4.2"
},
Expand Down
75 changes: 38 additions & 37 deletions ember-resources/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
// @ts-nocheck
import babel from '@rollup/plugin-babel';
import { defineConfig } from 'rollup';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import ts from 'rollup-plugin-ts';

import { Addon } from '@embroider/addon-dev/rollup';

const addon = new Addon();

const extensions = ['.js', '.ts', '.hbs'];

const transpilation = [
// Instruct rollup how to resolve ts and hbs imports
// (importing a template-only component, for example)
nodeResolve({ resolveOnly: ['./'], extensions }),

// This babel config should *not* apply presets or compile away ES modules.
// It exists only to provide development niceties for you, like automatic
// template colocation.
// See `babel.config.json` for the actual Babel configuration!
babel({ babelHelpers: 'bundled', extensions }),

// Follow the V2 Addon rules about dependencies. Your code can import from
// `dependencies` and `peerDependencies` as well as standard Ember-provided
// package names.
addon.dependencies(),

// Ensure that standalone .hbs files are properly integrated as Javascript.
// addon.hbs(),

// addons are allowed to contain imports of .css files, which we want rollup
// to leave alone and keep in the published output.
// addon.keepAssets(['**/*.css']),
];
const addon = new Addon({
srcDir: 'src',
destDir: 'dist',
});

// these should be JS, even though the authored format is TS
// Unfortunately, your local project layout has to kind of match what classic ember expects
// so that all the app-re-exports can be properly generated
// const globallyAvailable = ['components/**/*.js', 'instance-initializers/*.js', 'helpers/**/*.js'];

export default defineConfig({
input: ['src/index.ts'],
output: {
sourcemap: true,
format: 'es',
dir: 'dist',
},
output: addon.output(),
plugins: [
...transpilation,
// This babel config should *not* apply presets or compile away ES modules.
// It exists only to provide development niceties for you, like automatic
// template colocation.
// See `babel.config.json` for the actual Babel configuration!
ts({
// can be changed to swc or other transpilers later
// but we need the ember plugins converted first
// (template compilation and co-location)
transpiler: 'babel',
browserslist: ['last 2 firefox versions', 'last 2 chrome versions'],
// setting this true greatly improves performance, but
// at the cost of safety.
transpileOnly: false,
tsconfig: {
fileName: 'tsconfig.json',
hook: (config) => ({ ...config, declaration: true }),
},
}),

// Follow the V2 Addon rules about dependencies. Your code can import from
// `dependencies` and `peerDependencies` as well as standard Ember-provided
// package names.
addon.dependencies(),

// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints(['index.js']),
addon.publicEntrypoints(['*.{js,ts}']),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
// not everything in publicEntrypoints necessarily needs to go here.
// addon.appReexports([]),

// Ensure that standalone .hbs files are properly integrated as Javascript.
// addon.hbs(),

// addons are allowed to contain imports of .css files, which we want rollup
// to leave alone and keep in the published output.
// addon.keepAssets(['**/*.css']),

addon.clean(),
],
});
Loading

0 comments on commit 4ae8d86

Please sign in to comment.